state
stringlengths
0
159k
srcUpToTactic
stringlengths
387
167k
nextTactic
stringlengths
3
9k
declUpToTactic
stringlengths
22
11.5k
declId
stringlengths
38
95
decl
stringlengths
16
1.89k
file_tag
stringlengths
17
73
case mk.intro.intro.mk.intro.intro R : Type u_1 π•œ : Type u_2 B : Type u_3 F : Type u_4 E : B β†’ Type u_5 B' : Type u_6 f✝ : B' β†’ B inst✝¹¹ : TopologicalSpace B' inst✝¹⁰ : TopologicalSpace (TotalSpace F E) inst✝⁹ : NontriviallyNormedField π•œ inst✝⁸ : NormedAddCommGroup F inst✝⁷ : NormedSpace π•œ F inst✝⁢ : TopologicalSpace B inst✝⁡ : (x : B) β†’ AddCommMonoid (E x) inst✝⁴ : (x : B) β†’ Module π•œ (E x) K : Type u_7 inst✝³ : ContinuousMapClass K B' B inst✝² : (x : B) β†’ TopologicalSpace (E x) inst✝¹ : FiberBundle F E inst✝ : VectorBundle π•œ F E f : K e : Trivialization F TotalSpace.proj he : MemTrivializationAtlas e e' : Trivialization F TotalSpace.proj he' : MemTrivializationAtlas e' b : B' hb : f b ∈ e.baseSet ∩ e'.baseSet ⊒ (fun b => ↑(Trivialization.coordChangeL π•œ (Trivialization.pullback e f) (Trivialization.pullback e' f) b)) b = ((fun b => ↑(Trivialization.coordChangeL π•œ e e' b)) ∘ ⇑f) b
/- Copyright Β© 2022 NicolΓ² Cavalleri. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: NicolΓ² Cavalleri, SΓ©bastien GouΓ«zel, Heather Macbeth, Floris van Doorn -/ import Mathlib.Topology.FiberBundle.Constructions import Mathlib.Topology.VectorBundle.Basic #align_import topology.vector_bundle.constructions from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" /-! # Standard constructions on vector bundles This file contains several standard constructions on vector bundles: * `Bundle.Trivial.vectorBundle π•œ B F`: the trivial vector bundle with scalar field `π•œ` and model fiber `F` over the base `B` * `VectorBundle.prod`: for vector bundles `E₁` and `Eβ‚‚` with scalar field `π•œ` over a common base, a vector bundle structure on their direct sum `E₁ ×ᡇ Eβ‚‚` (the notation stands for `fun x ↦ E₁ x Γ— Eβ‚‚ x`). * `VectorBundle.pullback`: for a vector bundle `E` over `B`, a vector bundle structure on its pullback `f *α΅– E` by a map `f : B' β†’ B` (the notation is a type synonym for `E ∘ f`). ## Tags Vector bundle, direct sum, pullback -/ noncomputable section open Bundle Set FiberBundle Classical /-! ### The trivial vector bundle -/ namespace Bundle.Trivial variable (π•œ : Type*) (B : Type*) (F : Type*) [NontriviallyNormedField π•œ] [NormedAddCommGroup F] [NormedSpace π•œ F] [TopologicalSpace B] instance trivialization.isLinear : (trivialization B F).IsLinear π•œ where linear _ _ := ⟨fun _ _ => rfl, fun _ _ => rfl⟩ #align bundle.trivial.trivialization.is_linear Bundle.Trivial.trivialization.isLinear variable {π•œ} theorem trivialization.coordChangeL (b : B) : (trivialization B F).coordChangeL π•œ (trivialization B F) b = ContinuousLinearEquiv.refl π•œ F := by ext v rw [Trivialization.coordChangeL_apply'] exacts [rfl, ⟨mem_univ _, mem_univ _⟩] set_option linter.uppercaseLean3 false in #align bundle.trivial.trivialization.coord_changeL Bundle.Trivial.trivialization.coordChangeL variable (π•œ) instance vectorBundle : VectorBundle π•œ F (Bundle.Trivial B F) where trivialization_linear' e he := by rw [eq_trivialization B F e] infer_instance continuousOn_coordChange' e e' he he' := by obtain rfl := eq_trivialization B F e obtain rfl := eq_trivialization B F e' simp only [trivialization.coordChangeL] exact continuous_const.continuousOn #align bundle.trivial.vector_bundle Bundle.Trivial.vectorBundle end Bundle.Trivial /-! ### Direct sum of two vector bundles -/ section variable (π•œ : Type*) {B : Type*} [NontriviallyNormedField π•œ] [TopologicalSpace B] (F₁ : Type*) [NormedAddCommGroup F₁] [NormedSpace π•œ F₁] (E₁ : B β†’ Type*) [TopologicalSpace (TotalSpace F₁ E₁)] (Fβ‚‚ : Type*) [NormedAddCommGroup Fβ‚‚] [NormedSpace π•œ Fβ‚‚] (Eβ‚‚ : B β†’ Type*) [TopologicalSpace (TotalSpace Fβ‚‚ Eβ‚‚)] namespace Trivialization variable {F₁ E₁ Fβ‚‚ Eβ‚‚} variable [βˆ€ x, AddCommMonoid (E₁ x)] [βˆ€ x, Module π•œ (E₁ x)] [βˆ€ x, AddCommMonoid (Eβ‚‚ x)] [βˆ€ x, Module π•œ (Eβ‚‚ x)] (e₁ e₁' : Trivialization F₁ (Ο€ F₁ E₁)) (eβ‚‚ eβ‚‚' : Trivialization Fβ‚‚ (Ο€ Fβ‚‚ Eβ‚‚)) instance prod.isLinear [e₁.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] : (e₁.prod eβ‚‚).IsLinear π•œ where linear := fun _ ⟨h₁, hβ‚‚βŸ© => (((e₁.linear π•œ h₁).mk' _).prodMap ((eβ‚‚.linear π•œ hβ‚‚).mk' _)).isLinear #align trivialization.prod.is_linear Trivialization.prod.isLinear @[simp] theorem coordChangeL_prod [e₁.IsLinear π•œ] [e₁'.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] [eβ‚‚'.IsLinear π•œ] ⦃b⦄ (hb : b ∈ (e₁.prod eβ‚‚).baseSet ∩ (e₁'.prod eβ‚‚').baseSet) : ((e₁.prod eβ‚‚).coordChangeL π•œ (e₁'.prod eβ‚‚') b : F₁ Γ— Fβ‚‚ β†’L[π•œ] F₁ Γ— Fβ‚‚) = (e₁.coordChangeL π•œ e₁' b : F₁ β†’L[π•œ] F₁).prodMap (eβ‚‚.coordChangeL π•œ eβ‚‚' b) := by rw [ContinuousLinearMap.ext_iff, ContinuousLinearMap.coe_prodMap'] rintro ⟨v₁, vβ‚‚βŸ© show (e₁.prod eβ‚‚).coordChangeL π•œ (e₁'.prod eβ‚‚') b (v₁, vβ‚‚) = (e₁.coordChangeL π•œ e₁' b v₁, eβ‚‚.coordChangeL π•œ eβ‚‚' b vβ‚‚) rw [e₁.coordChangeL_apply e₁', eβ‚‚.coordChangeL_apply eβ‚‚', (e₁.prod eβ‚‚).coordChangeL_apply'] exacts [rfl, hb, ⟨hb.1.2, hb.2.2⟩, ⟨hb.1.1, hb.2.1⟩] set_option linter.uppercaseLean3 false in #align trivialization.coord_changeL_prod Trivialization.coordChangeL_prod variable {e₁ eβ‚‚} [βˆ€ x : B, TopologicalSpace (E₁ x)] [βˆ€ x : B, TopologicalSpace (Eβ‚‚ x)] [FiberBundle F₁ E₁] [FiberBundle Fβ‚‚ Eβ‚‚] theorem prod_apply [e₁.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] {x : B} (hx₁ : x ∈ e₁.baseSet) (hxβ‚‚ : x ∈ eβ‚‚.baseSet) (v₁ : E₁ x) (vβ‚‚ : Eβ‚‚ x) : prod e₁ eβ‚‚ ⟨x, (v₁, vβ‚‚)⟩ = ⟨x, e₁.continuousLinearEquivAt π•œ x hx₁ v₁, eβ‚‚.continuousLinearEquivAt π•œ x hxβ‚‚ vβ‚‚βŸ© := rfl #align trivialization.prod_apply Trivialization.prod_apply end Trivialization open Trivialization variable [βˆ€ x, AddCommMonoid (E₁ x)] [βˆ€ x, Module π•œ (E₁ x)] [βˆ€ x, AddCommMonoid (Eβ‚‚ x)] [βˆ€ x, Module π•œ (Eβ‚‚ x)] [βˆ€ x : B, TopologicalSpace (E₁ x)] [βˆ€ x : B, TopologicalSpace (Eβ‚‚ x)] [FiberBundle F₁ E₁] [FiberBundle Fβ‚‚ Eβ‚‚] /-- The product of two vector bundles is a vector bundle. -/ instance VectorBundle.prod [VectorBundle π•œ F₁ E₁] [VectorBundle π•œ Fβ‚‚ Eβ‚‚] : VectorBundle π•œ (F₁ Γ— Fβ‚‚) (E₁ ×ᡇ Eβ‚‚) where trivialization_linear' := by rintro _ ⟨e₁, eβ‚‚, he₁, heβ‚‚, rfl⟩; skip infer_instance continuousOn_coordChange' := by rintro _ _ ⟨e₁, eβ‚‚, he₁, heβ‚‚, rfl⟩ ⟨e₁', eβ‚‚', he₁', heβ‚‚', rfl⟩; skip refine' (((continuousOn_coordChange π•œ e₁ e₁').mono _).prod_mapL π•œ ((continuousOn_coordChange π•œ eβ‚‚ eβ‚‚').mono _)).congr _ <;> dsimp only [baseSet_prod, mfld_simps] Β· mfld_set_tac Β· mfld_set_tac Β· rintro b hb rw [ContinuousLinearMap.ext_iff] rintro ⟨v₁, vβ‚‚βŸ© show (e₁.prod eβ‚‚).coordChangeL π•œ (e₁'.prod eβ‚‚') b (v₁, vβ‚‚) = (e₁.coordChangeL π•œ e₁' b v₁, eβ‚‚.coordChangeL π•œ eβ‚‚' b vβ‚‚) rw [e₁.coordChangeL_apply e₁', eβ‚‚.coordChangeL_apply eβ‚‚', (e₁.prod eβ‚‚).coordChangeL_apply'] exacts [rfl, hb, ⟨hb.1.2, hb.2.2⟩, ⟨hb.1.1, hb.2.1⟩] #align vector_bundle.prod VectorBundle.prod variable {π•œ F₁ E₁ Fβ‚‚ Eβ‚‚} @[simp] -- porting note: changed arguments to make `simpNF` happy: merged `hx₁` and `hxβ‚‚` into `hx` theorem Trivialization.continuousLinearEquivAt_prod {e₁ : Trivialization F₁ (Ο€ F₁ E₁)} {eβ‚‚ : Trivialization Fβ‚‚ (Ο€ Fβ‚‚ Eβ‚‚)} [e₁.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] {x : B} (hx : x ∈ (e₁.prod eβ‚‚).baseSet) : (e₁.prod eβ‚‚).continuousLinearEquivAt π•œ x hx = (e₁.continuousLinearEquivAt π•œ x hx.1).prod (eβ‚‚.continuousLinearEquivAt π•œ x hx.2) := by ext v : 2 obtain ⟨v₁, vβ‚‚βŸ© := v rw [(e₁.prod eβ‚‚).continuousLinearEquivAt_apply π•œ, Trivialization.prod] exact (congr_arg Prod.snd (prod_apply π•œ hx.1 hx.2 v₁ vβ‚‚) : _) #align trivialization.continuous_linear_equiv_at_prod Trivialization.continuousLinearEquivAt_prodβ‚“ end /-! ### Pullbacks of vector bundles -/ section variable (R π•œ : Type*) {B : Type*} (F : Type*) (E : B β†’ Type*) {B' : Type*} (f : B' β†’ B) instance [i : βˆ€ x : B, AddCommMonoid (E x)] (x : B') : AddCommMonoid ((f *α΅– E) x) := i _ instance [Semiring R] [βˆ€ x : B, AddCommMonoid (E x)] [i : βˆ€ x, Module R (E x)] (x : B') : Module R ((f *α΅– E) x) := i _ variable {E F} [TopologicalSpace B'] [TopologicalSpace (TotalSpace F E)] [NontriviallyNormedField π•œ] [NormedAddCommGroup F] [NormedSpace π•œ F] [TopologicalSpace B] [βˆ€ x, AddCommMonoid (E x)] [βˆ€ x, Module π•œ (E x)] {K : Type*} [ContinuousMapClass K B' B] instance Trivialization.pullback_linear (e : Trivialization F (Ο€ F E)) [e.IsLinear π•œ] (f : K) : (@Trivialization.pullback _ _ _ B' _ _ _ _ _ _ _ e f).IsLinear π•œ where linear _ h := e.linear π•œ h #align trivialization.pullback_linear Trivialization.pullback_linear instance VectorBundle.pullback [βˆ€ x, TopologicalSpace (E x)] [FiberBundle F E] [VectorBundle π•œ F E] (f : K) : VectorBundle π•œ F ((f : B' β†’ B) *α΅– E) where trivialization_linear' := by rintro _ ⟨e, he, rfl⟩ infer_instance continuousOn_coordChange' := by rintro _ _ ⟨e, he, rfl⟩ ⟨e', he', rfl⟩ refine' ((continuousOn_coordChange π•œ e e').comp (map_continuous f).continuousOn fun b hb => hb).congr _ rintro b (hb : f b ∈ e.baseSet ∩ e'.baseSet);
ext v
instance VectorBundle.pullback [βˆ€ x, TopologicalSpace (E x)] [FiberBundle F E] [VectorBundle π•œ F E] (f : K) : VectorBundle π•œ F ((f : B' β†’ B) *α΅– E) where trivialization_linear' := by rintro _ ⟨e, he, rfl⟩ infer_instance continuousOn_coordChange' := by rintro _ _ ⟨e, he, rfl⟩ ⟨e', he', rfl⟩ refine' ((continuousOn_coordChange π•œ e e').comp (map_continuous f).continuousOn fun b hb => hb).congr _ rintro b (hb : f b ∈ e.baseSet ∩ e'.baseSet);
Mathlib.Topology.VectorBundle.Constructions.184_0.ZrgS90NPsSlDzPQ
instance VectorBundle.pullback [βˆ€ x, TopologicalSpace (E x)] [FiberBundle F E] [VectorBundle π•œ F E] (f : K) : VectorBundle π•œ F ((f : B' β†’ B) *α΅– E) where trivialization_linear'
Mathlib_Topology_VectorBundle_Constructions
case mk.intro.intro.mk.intro.intro.h R : Type u_1 π•œ : Type u_2 B : Type u_3 F : Type u_4 E : B β†’ Type u_5 B' : Type u_6 f✝ : B' β†’ B inst✝¹¹ : TopologicalSpace B' inst✝¹⁰ : TopologicalSpace (TotalSpace F E) inst✝⁹ : NontriviallyNormedField π•œ inst✝⁸ : NormedAddCommGroup F inst✝⁷ : NormedSpace π•œ F inst✝⁢ : TopologicalSpace B inst✝⁡ : (x : B) β†’ AddCommMonoid (E x) inst✝⁴ : (x : B) β†’ Module π•œ (E x) K : Type u_7 inst✝³ : ContinuousMapClass K B' B inst✝² : (x : B) β†’ TopologicalSpace (E x) inst✝¹ : FiberBundle F E inst✝ : VectorBundle π•œ F E f : K e : Trivialization F TotalSpace.proj he : MemTrivializationAtlas e e' : Trivialization F TotalSpace.proj he' : MemTrivializationAtlas e' b : B' hb : f b ∈ e.baseSet ∩ e'.baseSet v : F ⊒ ((fun b => ↑(Trivialization.coordChangeL π•œ (Trivialization.pullback e f) (Trivialization.pullback e' f) b)) b) v = (((fun b => ↑(Trivialization.coordChangeL π•œ e e' b)) ∘ ⇑f) b) v
/- Copyright Β© 2022 NicolΓ² Cavalleri. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: NicolΓ² Cavalleri, SΓ©bastien GouΓ«zel, Heather Macbeth, Floris van Doorn -/ import Mathlib.Topology.FiberBundle.Constructions import Mathlib.Topology.VectorBundle.Basic #align_import topology.vector_bundle.constructions from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" /-! # Standard constructions on vector bundles This file contains several standard constructions on vector bundles: * `Bundle.Trivial.vectorBundle π•œ B F`: the trivial vector bundle with scalar field `π•œ` and model fiber `F` over the base `B` * `VectorBundle.prod`: for vector bundles `E₁` and `Eβ‚‚` with scalar field `π•œ` over a common base, a vector bundle structure on their direct sum `E₁ ×ᡇ Eβ‚‚` (the notation stands for `fun x ↦ E₁ x Γ— Eβ‚‚ x`). * `VectorBundle.pullback`: for a vector bundle `E` over `B`, a vector bundle structure on its pullback `f *α΅– E` by a map `f : B' β†’ B` (the notation is a type synonym for `E ∘ f`). ## Tags Vector bundle, direct sum, pullback -/ noncomputable section open Bundle Set FiberBundle Classical /-! ### The trivial vector bundle -/ namespace Bundle.Trivial variable (π•œ : Type*) (B : Type*) (F : Type*) [NontriviallyNormedField π•œ] [NormedAddCommGroup F] [NormedSpace π•œ F] [TopologicalSpace B] instance trivialization.isLinear : (trivialization B F).IsLinear π•œ where linear _ _ := ⟨fun _ _ => rfl, fun _ _ => rfl⟩ #align bundle.trivial.trivialization.is_linear Bundle.Trivial.trivialization.isLinear variable {π•œ} theorem trivialization.coordChangeL (b : B) : (trivialization B F).coordChangeL π•œ (trivialization B F) b = ContinuousLinearEquiv.refl π•œ F := by ext v rw [Trivialization.coordChangeL_apply'] exacts [rfl, ⟨mem_univ _, mem_univ _⟩] set_option linter.uppercaseLean3 false in #align bundle.trivial.trivialization.coord_changeL Bundle.Trivial.trivialization.coordChangeL variable (π•œ) instance vectorBundle : VectorBundle π•œ F (Bundle.Trivial B F) where trivialization_linear' e he := by rw [eq_trivialization B F e] infer_instance continuousOn_coordChange' e e' he he' := by obtain rfl := eq_trivialization B F e obtain rfl := eq_trivialization B F e' simp only [trivialization.coordChangeL] exact continuous_const.continuousOn #align bundle.trivial.vector_bundle Bundle.Trivial.vectorBundle end Bundle.Trivial /-! ### Direct sum of two vector bundles -/ section variable (π•œ : Type*) {B : Type*} [NontriviallyNormedField π•œ] [TopologicalSpace B] (F₁ : Type*) [NormedAddCommGroup F₁] [NormedSpace π•œ F₁] (E₁ : B β†’ Type*) [TopologicalSpace (TotalSpace F₁ E₁)] (Fβ‚‚ : Type*) [NormedAddCommGroup Fβ‚‚] [NormedSpace π•œ Fβ‚‚] (Eβ‚‚ : B β†’ Type*) [TopologicalSpace (TotalSpace Fβ‚‚ Eβ‚‚)] namespace Trivialization variable {F₁ E₁ Fβ‚‚ Eβ‚‚} variable [βˆ€ x, AddCommMonoid (E₁ x)] [βˆ€ x, Module π•œ (E₁ x)] [βˆ€ x, AddCommMonoid (Eβ‚‚ x)] [βˆ€ x, Module π•œ (Eβ‚‚ x)] (e₁ e₁' : Trivialization F₁ (Ο€ F₁ E₁)) (eβ‚‚ eβ‚‚' : Trivialization Fβ‚‚ (Ο€ Fβ‚‚ Eβ‚‚)) instance prod.isLinear [e₁.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] : (e₁.prod eβ‚‚).IsLinear π•œ where linear := fun _ ⟨h₁, hβ‚‚βŸ© => (((e₁.linear π•œ h₁).mk' _).prodMap ((eβ‚‚.linear π•œ hβ‚‚).mk' _)).isLinear #align trivialization.prod.is_linear Trivialization.prod.isLinear @[simp] theorem coordChangeL_prod [e₁.IsLinear π•œ] [e₁'.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] [eβ‚‚'.IsLinear π•œ] ⦃b⦄ (hb : b ∈ (e₁.prod eβ‚‚).baseSet ∩ (e₁'.prod eβ‚‚').baseSet) : ((e₁.prod eβ‚‚).coordChangeL π•œ (e₁'.prod eβ‚‚') b : F₁ Γ— Fβ‚‚ β†’L[π•œ] F₁ Γ— Fβ‚‚) = (e₁.coordChangeL π•œ e₁' b : F₁ β†’L[π•œ] F₁).prodMap (eβ‚‚.coordChangeL π•œ eβ‚‚' b) := by rw [ContinuousLinearMap.ext_iff, ContinuousLinearMap.coe_prodMap'] rintro ⟨v₁, vβ‚‚βŸ© show (e₁.prod eβ‚‚).coordChangeL π•œ (e₁'.prod eβ‚‚') b (v₁, vβ‚‚) = (e₁.coordChangeL π•œ e₁' b v₁, eβ‚‚.coordChangeL π•œ eβ‚‚' b vβ‚‚) rw [e₁.coordChangeL_apply e₁', eβ‚‚.coordChangeL_apply eβ‚‚', (e₁.prod eβ‚‚).coordChangeL_apply'] exacts [rfl, hb, ⟨hb.1.2, hb.2.2⟩, ⟨hb.1.1, hb.2.1⟩] set_option linter.uppercaseLean3 false in #align trivialization.coord_changeL_prod Trivialization.coordChangeL_prod variable {e₁ eβ‚‚} [βˆ€ x : B, TopologicalSpace (E₁ x)] [βˆ€ x : B, TopologicalSpace (Eβ‚‚ x)] [FiberBundle F₁ E₁] [FiberBundle Fβ‚‚ Eβ‚‚] theorem prod_apply [e₁.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] {x : B} (hx₁ : x ∈ e₁.baseSet) (hxβ‚‚ : x ∈ eβ‚‚.baseSet) (v₁ : E₁ x) (vβ‚‚ : Eβ‚‚ x) : prod e₁ eβ‚‚ ⟨x, (v₁, vβ‚‚)⟩ = ⟨x, e₁.continuousLinearEquivAt π•œ x hx₁ v₁, eβ‚‚.continuousLinearEquivAt π•œ x hxβ‚‚ vβ‚‚βŸ© := rfl #align trivialization.prod_apply Trivialization.prod_apply end Trivialization open Trivialization variable [βˆ€ x, AddCommMonoid (E₁ x)] [βˆ€ x, Module π•œ (E₁ x)] [βˆ€ x, AddCommMonoid (Eβ‚‚ x)] [βˆ€ x, Module π•œ (Eβ‚‚ x)] [βˆ€ x : B, TopologicalSpace (E₁ x)] [βˆ€ x : B, TopologicalSpace (Eβ‚‚ x)] [FiberBundle F₁ E₁] [FiberBundle Fβ‚‚ Eβ‚‚] /-- The product of two vector bundles is a vector bundle. -/ instance VectorBundle.prod [VectorBundle π•œ F₁ E₁] [VectorBundle π•œ Fβ‚‚ Eβ‚‚] : VectorBundle π•œ (F₁ Γ— Fβ‚‚) (E₁ ×ᡇ Eβ‚‚) where trivialization_linear' := by rintro _ ⟨e₁, eβ‚‚, he₁, heβ‚‚, rfl⟩; skip infer_instance continuousOn_coordChange' := by rintro _ _ ⟨e₁, eβ‚‚, he₁, heβ‚‚, rfl⟩ ⟨e₁', eβ‚‚', he₁', heβ‚‚', rfl⟩; skip refine' (((continuousOn_coordChange π•œ e₁ e₁').mono _).prod_mapL π•œ ((continuousOn_coordChange π•œ eβ‚‚ eβ‚‚').mono _)).congr _ <;> dsimp only [baseSet_prod, mfld_simps] Β· mfld_set_tac Β· mfld_set_tac Β· rintro b hb rw [ContinuousLinearMap.ext_iff] rintro ⟨v₁, vβ‚‚βŸ© show (e₁.prod eβ‚‚).coordChangeL π•œ (e₁'.prod eβ‚‚') b (v₁, vβ‚‚) = (e₁.coordChangeL π•œ e₁' b v₁, eβ‚‚.coordChangeL π•œ eβ‚‚' b vβ‚‚) rw [e₁.coordChangeL_apply e₁', eβ‚‚.coordChangeL_apply eβ‚‚', (e₁.prod eβ‚‚).coordChangeL_apply'] exacts [rfl, hb, ⟨hb.1.2, hb.2.2⟩, ⟨hb.1.1, hb.2.1⟩] #align vector_bundle.prod VectorBundle.prod variable {π•œ F₁ E₁ Fβ‚‚ Eβ‚‚} @[simp] -- porting note: changed arguments to make `simpNF` happy: merged `hx₁` and `hxβ‚‚` into `hx` theorem Trivialization.continuousLinearEquivAt_prod {e₁ : Trivialization F₁ (Ο€ F₁ E₁)} {eβ‚‚ : Trivialization Fβ‚‚ (Ο€ Fβ‚‚ Eβ‚‚)} [e₁.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] {x : B} (hx : x ∈ (e₁.prod eβ‚‚).baseSet) : (e₁.prod eβ‚‚).continuousLinearEquivAt π•œ x hx = (e₁.continuousLinearEquivAt π•œ x hx.1).prod (eβ‚‚.continuousLinearEquivAt π•œ x hx.2) := by ext v : 2 obtain ⟨v₁, vβ‚‚βŸ© := v rw [(e₁.prod eβ‚‚).continuousLinearEquivAt_apply π•œ, Trivialization.prod] exact (congr_arg Prod.snd (prod_apply π•œ hx.1 hx.2 v₁ vβ‚‚) : _) #align trivialization.continuous_linear_equiv_at_prod Trivialization.continuousLinearEquivAt_prodβ‚“ end /-! ### Pullbacks of vector bundles -/ section variable (R π•œ : Type*) {B : Type*} (F : Type*) (E : B β†’ Type*) {B' : Type*} (f : B' β†’ B) instance [i : βˆ€ x : B, AddCommMonoid (E x)] (x : B') : AddCommMonoid ((f *α΅– E) x) := i _ instance [Semiring R] [βˆ€ x : B, AddCommMonoid (E x)] [i : βˆ€ x, Module R (E x)] (x : B') : Module R ((f *α΅– E) x) := i _ variable {E F} [TopologicalSpace B'] [TopologicalSpace (TotalSpace F E)] [NontriviallyNormedField π•œ] [NormedAddCommGroup F] [NormedSpace π•œ F] [TopologicalSpace B] [βˆ€ x, AddCommMonoid (E x)] [βˆ€ x, Module π•œ (E x)] {K : Type*} [ContinuousMapClass K B' B] instance Trivialization.pullback_linear (e : Trivialization F (Ο€ F E)) [e.IsLinear π•œ] (f : K) : (@Trivialization.pullback _ _ _ B' _ _ _ _ _ _ _ e f).IsLinear π•œ where linear _ h := e.linear π•œ h #align trivialization.pullback_linear Trivialization.pullback_linear instance VectorBundle.pullback [βˆ€ x, TopologicalSpace (E x)] [FiberBundle F E] [VectorBundle π•œ F E] (f : K) : VectorBundle π•œ F ((f : B' β†’ B) *α΅– E) where trivialization_linear' := by rintro _ ⟨e, he, rfl⟩ infer_instance continuousOn_coordChange' := by rintro _ _ ⟨e, he, rfl⟩ ⟨e', he', rfl⟩ refine' ((continuousOn_coordChange π•œ e e').comp (map_continuous f).continuousOn fun b hb => hb).congr _ rintro b (hb : f b ∈ e.baseSet ∩ e'.baseSet); ext v
show ((e.pullback f).coordChangeL π•œ (e'.pullback f) b) v = (e.coordChangeL π•œ e' (f b)) v
instance VectorBundle.pullback [βˆ€ x, TopologicalSpace (E x)] [FiberBundle F E] [VectorBundle π•œ F E] (f : K) : VectorBundle π•œ F ((f : B' β†’ B) *α΅– E) where trivialization_linear' := by rintro _ ⟨e, he, rfl⟩ infer_instance continuousOn_coordChange' := by rintro _ _ ⟨e, he, rfl⟩ ⟨e', he', rfl⟩ refine' ((continuousOn_coordChange π•œ e e').comp (map_continuous f).continuousOn fun b hb => hb).congr _ rintro b (hb : f b ∈ e.baseSet ∩ e'.baseSet); ext v
Mathlib.Topology.VectorBundle.Constructions.184_0.ZrgS90NPsSlDzPQ
instance VectorBundle.pullback [βˆ€ x, TopologicalSpace (E x)] [FiberBundle F E] [VectorBundle π•œ F E] (f : K) : VectorBundle π•œ F ((f : B' β†’ B) *α΅– E) where trivialization_linear'
Mathlib_Topology_VectorBundle_Constructions
case mk.intro.intro.mk.intro.intro.h R : Type u_1 π•œ : Type u_2 B : Type u_3 F : Type u_4 E : B β†’ Type u_5 B' : Type u_6 f✝ : B' β†’ B inst✝¹¹ : TopologicalSpace B' inst✝¹⁰ : TopologicalSpace (TotalSpace F E) inst✝⁹ : NontriviallyNormedField π•œ inst✝⁸ : NormedAddCommGroup F inst✝⁷ : NormedSpace π•œ F inst✝⁢ : TopologicalSpace B inst✝⁡ : (x : B) β†’ AddCommMonoid (E x) inst✝⁴ : (x : B) β†’ Module π•œ (E x) K : Type u_7 inst✝³ : ContinuousMapClass K B' B inst✝² : (x : B) β†’ TopologicalSpace (E x) inst✝¹ : FiberBundle F E inst✝ : VectorBundle π•œ F E f : K e : Trivialization F TotalSpace.proj he : MemTrivializationAtlas e e' : Trivialization F TotalSpace.proj he' : MemTrivializationAtlas e' b : B' hb : f b ∈ e.baseSet ∩ e'.baseSet v : F ⊒ (Trivialization.coordChangeL π•œ (Trivialization.pullback e f) (Trivialization.pullback e' f) b) v = (Trivialization.coordChangeL π•œ e e' (f b)) v
/- Copyright Β© 2022 NicolΓ² Cavalleri. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: NicolΓ² Cavalleri, SΓ©bastien GouΓ«zel, Heather Macbeth, Floris van Doorn -/ import Mathlib.Topology.FiberBundle.Constructions import Mathlib.Topology.VectorBundle.Basic #align_import topology.vector_bundle.constructions from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" /-! # Standard constructions on vector bundles This file contains several standard constructions on vector bundles: * `Bundle.Trivial.vectorBundle π•œ B F`: the trivial vector bundle with scalar field `π•œ` and model fiber `F` over the base `B` * `VectorBundle.prod`: for vector bundles `E₁` and `Eβ‚‚` with scalar field `π•œ` over a common base, a vector bundle structure on their direct sum `E₁ ×ᡇ Eβ‚‚` (the notation stands for `fun x ↦ E₁ x Γ— Eβ‚‚ x`). * `VectorBundle.pullback`: for a vector bundle `E` over `B`, a vector bundle structure on its pullback `f *α΅– E` by a map `f : B' β†’ B` (the notation is a type synonym for `E ∘ f`). ## Tags Vector bundle, direct sum, pullback -/ noncomputable section open Bundle Set FiberBundle Classical /-! ### The trivial vector bundle -/ namespace Bundle.Trivial variable (π•œ : Type*) (B : Type*) (F : Type*) [NontriviallyNormedField π•œ] [NormedAddCommGroup F] [NormedSpace π•œ F] [TopologicalSpace B] instance trivialization.isLinear : (trivialization B F).IsLinear π•œ where linear _ _ := ⟨fun _ _ => rfl, fun _ _ => rfl⟩ #align bundle.trivial.trivialization.is_linear Bundle.Trivial.trivialization.isLinear variable {π•œ} theorem trivialization.coordChangeL (b : B) : (trivialization B F).coordChangeL π•œ (trivialization B F) b = ContinuousLinearEquiv.refl π•œ F := by ext v rw [Trivialization.coordChangeL_apply'] exacts [rfl, ⟨mem_univ _, mem_univ _⟩] set_option linter.uppercaseLean3 false in #align bundle.trivial.trivialization.coord_changeL Bundle.Trivial.trivialization.coordChangeL variable (π•œ) instance vectorBundle : VectorBundle π•œ F (Bundle.Trivial B F) where trivialization_linear' e he := by rw [eq_trivialization B F e] infer_instance continuousOn_coordChange' e e' he he' := by obtain rfl := eq_trivialization B F e obtain rfl := eq_trivialization B F e' simp only [trivialization.coordChangeL] exact continuous_const.continuousOn #align bundle.trivial.vector_bundle Bundle.Trivial.vectorBundle end Bundle.Trivial /-! ### Direct sum of two vector bundles -/ section variable (π•œ : Type*) {B : Type*} [NontriviallyNormedField π•œ] [TopologicalSpace B] (F₁ : Type*) [NormedAddCommGroup F₁] [NormedSpace π•œ F₁] (E₁ : B β†’ Type*) [TopologicalSpace (TotalSpace F₁ E₁)] (Fβ‚‚ : Type*) [NormedAddCommGroup Fβ‚‚] [NormedSpace π•œ Fβ‚‚] (Eβ‚‚ : B β†’ Type*) [TopologicalSpace (TotalSpace Fβ‚‚ Eβ‚‚)] namespace Trivialization variable {F₁ E₁ Fβ‚‚ Eβ‚‚} variable [βˆ€ x, AddCommMonoid (E₁ x)] [βˆ€ x, Module π•œ (E₁ x)] [βˆ€ x, AddCommMonoid (Eβ‚‚ x)] [βˆ€ x, Module π•œ (Eβ‚‚ x)] (e₁ e₁' : Trivialization F₁ (Ο€ F₁ E₁)) (eβ‚‚ eβ‚‚' : Trivialization Fβ‚‚ (Ο€ Fβ‚‚ Eβ‚‚)) instance prod.isLinear [e₁.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] : (e₁.prod eβ‚‚).IsLinear π•œ where linear := fun _ ⟨h₁, hβ‚‚βŸ© => (((e₁.linear π•œ h₁).mk' _).prodMap ((eβ‚‚.linear π•œ hβ‚‚).mk' _)).isLinear #align trivialization.prod.is_linear Trivialization.prod.isLinear @[simp] theorem coordChangeL_prod [e₁.IsLinear π•œ] [e₁'.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] [eβ‚‚'.IsLinear π•œ] ⦃b⦄ (hb : b ∈ (e₁.prod eβ‚‚).baseSet ∩ (e₁'.prod eβ‚‚').baseSet) : ((e₁.prod eβ‚‚).coordChangeL π•œ (e₁'.prod eβ‚‚') b : F₁ Γ— Fβ‚‚ β†’L[π•œ] F₁ Γ— Fβ‚‚) = (e₁.coordChangeL π•œ e₁' b : F₁ β†’L[π•œ] F₁).prodMap (eβ‚‚.coordChangeL π•œ eβ‚‚' b) := by rw [ContinuousLinearMap.ext_iff, ContinuousLinearMap.coe_prodMap'] rintro ⟨v₁, vβ‚‚βŸ© show (e₁.prod eβ‚‚).coordChangeL π•œ (e₁'.prod eβ‚‚') b (v₁, vβ‚‚) = (e₁.coordChangeL π•œ e₁' b v₁, eβ‚‚.coordChangeL π•œ eβ‚‚' b vβ‚‚) rw [e₁.coordChangeL_apply e₁', eβ‚‚.coordChangeL_apply eβ‚‚', (e₁.prod eβ‚‚).coordChangeL_apply'] exacts [rfl, hb, ⟨hb.1.2, hb.2.2⟩, ⟨hb.1.1, hb.2.1⟩] set_option linter.uppercaseLean3 false in #align trivialization.coord_changeL_prod Trivialization.coordChangeL_prod variable {e₁ eβ‚‚} [βˆ€ x : B, TopologicalSpace (E₁ x)] [βˆ€ x : B, TopologicalSpace (Eβ‚‚ x)] [FiberBundle F₁ E₁] [FiberBundle Fβ‚‚ Eβ‚‚] theorem prod_apply [e₁.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] {x : B} (hx₁ : x ∈ e₁.baseSet) (hxβ‚‚ : x ∈ eβ‚‚.baseSet) (v₁ : E₁ x) (vβ‚‚ : Eβ‚‚ x) : prod e₁ eβ‚‚ ⟨x, (v₁, vβ‚‚)⟩ = ⟨x, e₁.continuousLinearEquivAt π•œ x hx₁ v₁, eβ‚‚.continuousLinearEquivAt π•œ x hxβ‚‚ vβ‚‚βŸ© := rfl #align trivialization.prod_apply Trivialization.prod_apply end Trivialization open Trivialization variable [βˆ€ x, AddCommMonoid (E₁ x)] [βˆ€ x, Module π•œ (E₁ x)] [βˆ€ x, AddCommMonoid (Eβ‚‚ x)] [βˆ€ x, Module π•œ (Eβ‚‚ x)] [βˆ€ x : B, TopologicalSpace (E₁ x)] [βˆ€ x : B, TopologicalSpace (Eβ‚‚ x)] [FiberBundle F₁ E₁] [FiberBundle Fβ‚‚ Eβ‚‚] /-- The product of two vector bundles is a vector bundle. -/ instance VectorBundle.prod [VectorBundle π•œ F₁ E₁] [VectorBundle π•œ Fβ‚‚ Eβ‚‚] : VectorBundle π•œ (F₁ Γ— Fβ‚‚) (E₁ ×ᡇ Eβ‚‚) where trivialization_linear' := by rintro _ ⟨e₁, eβ‚‚, he₁, heβ‚‚, rfl⟩; skip infer_instance continuousOn_coordChange' := by rintro _ _ ⟨e₁, eβ‚‚, he₁, heβ‚‚, rfl⟩ ⟨e₁', eβ‚‚', he₁', heβ‚‚', rfl⟩; skip refine' (((continuousOn_coordChange π•œ e₁ e₁').mono _).prod_mapL π•œ ((continuousOn_coordChange π•œ eβ‚‚ eβ‚‚').mono _)).congr _ <;> dsimp only [baseSet_prod, mfld_simps] Β· mfld_set_tac Β· mfld_set_tac Β· rintro b hb rw [ContinuousLinearMap.ext_iff] rintro ⟨v₁, vβ‚‚βŸ© show (e₁.prod eβ‚‚).coordChangeL π•œ (e₁'.prod eβ‚‚') b (v₁, vβ‚‚) = (e₁.coordChangeL π•œ e₁' b v₁, eβ‚‚.coordChangeL π•œ eβ‚‚' b vβ‚‚) rw [e₁.coordChangeL_apply e₁', eβ‚‚.coordChangeL_apply eβ‚‚', (e₁.prod eβ‚‚).coordChangeL_apply'] exacts [rfl, hb, ⟨hb.1.2, hb.2.2⟩, ⟨hb.1.1, hb.2.1⟩] #align vector_bundle.prod VectorBundle.prod variable {π•œ F₁ E₁ Fβ‚‚ Eβ‚‚} @[simp] -- porting note: changed arguments to make `simpNF` happy: merged `hx₁` and `hxβ‚‚` into `hx` theorem Trivialization.continuousLinearEquivAt_prod {e₁ : Trivialization F₁ (Ο€ F₁ E₁)} {eβ‚‚ : Trivialization Fβ‚‚ (Ο€ Fβ‚‚ Eβ‚‚)} [e₁.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] {x : B} (hx : x ∈ (e₁.prod eβ‚‚).baseSet) : (e₁.prod eβ‚‚).continuousLinearEquivAt π•œ x hx = (e₁.continuousLinearEquivAt π•œ x hx.1).prod (eβ‚‚.continuousLinearEquivAt π•œ x hx.2) := by ext v : 2 obtain ⟨v₁, vβ‚‚βŸ© := v rw [(e₁.prod eβ‚‚).continuousLinearEquivAt_apply π•œ, Trivialization.prod] exact (congr_arg Prod.snd (prod_apply π•œ hx.1 hx.2 v₁ vβ‚‚) : _) #align trivialization.continuous_linear_equiv_at_prod Trivialization.continuousLinearEquivAt_prodβ‚“ end /-! ### Pullbacks of vector bundles -/ section variable (R π•œ : Type*) {B : Type*} (F : Type*) (E : B β†’ Type*) {B' : Type*} (f : B' β†’ B) instance [i : βˆ€ x : B, AddCommMonoid (E x)] (x : B') : AddCommMonoid ((f *α΅– E) x) := i _ instance [Semiring R] [βˆ€ x : B, AddCommMonoid (E x)] [i : βˆ€ x, Module R (E x)] (x : B') : Module R ((f *α΅– E) x) := i _ variable {E F} [TopologicalSpace B'] [TopologicalSpace (TotalSpace F E)] [NontriviallyNormedField π•œ] [NormedAddCommGroup F] [NormedSpace π•œ F] [TopologicalSpace B] [βˆ€ x, AddCommMonoid (E x)] [βˆ€ x, Module π•œ (E x)] {K : Type*} [ContinuousMapClass K B' B] instance Trivialization.pullback_linear (e : Trivialization F (Ο€ F E)) [e.IsLinear π•œ] (f : K) : (@Trivialization.pullback _ _ _ B' _ _ _ _ _ _ _ e f).IsLinear π•œ where linear _ h := e.linear π•œ h #align trivialization.pullback_linear Trivialization.pullback_linear instance VectorBundle.pullback [βˆ€ x, TopologicalSpace (E x)] [FiberBundle F E] [VectorBundle π•œ F E] (f : K) : VectorBundle π•œ F ((f : B' β†’ B) *α΅– E) where trivialization_linear' := by rintro _ ⟨e, he, rfl⟩ infer_instance continuousOn_coordChange' := by rintro _ _ ⟨e, he, rfl⟩ ⟨e', he', rfl⟩ refine' ((continuousOn_coordChange π•œ e e').comp (map_continuous f).continuousOn fun b hb => hb).congr _ rintro b (hb : f b ∈ e.baseSet ∩ e'.baseSet); ext v show ((e.pullback f).coordChangeL π•œ (e'.pullback f) b) v = (e.coordChangeL π•œ e' (f b)) v
rw [e.coordChangeL_apply e' hb, (e.pullback f).coordChangeL_apply' _]
instance VectorBundle.pullback [βˆ€ x, TopologicalSpace (E x)] [FiberBundle F E] [VectorBundle π•œ F E] (f : K) : VectorBundle π•œ F ((f : B' β†’ B) *α΅– E) where trivialization_linear' := by rintro _ ⟨e, he, rfl⟩ infer_instance continuousOn_coordChange' := by rintro _ _ ⟨e, he, rfl⟩ ⟨e', he', rfl⟩ refine' ((continuousOn_coordChange π•œ e e').comp (map_continuous f).continuousOn fun b hb => hb).congr _ rintro b (hb : f b ∈ e.baseSet ∩ e'.baseSet); ext v show ((e.pullback f).coordChangeL π•œ (e'.pullback f) b) v = (e.coordChangeL π•œ e' (f b)) v
Mathlib.Topology.VectorBundle.Constructions.184_0.ZrgS90NPsSlDzPQ
instance VectorBundle.pullback [βˆ€ x, TopologicalSpace (E x)] [FiberBundle F E] [VectorBundle π•œ F E] (f : K) : VectorBundle π•œ F ((f : B' β†’ B) *α΅– E) where trivialization_linear'
Mathlib_Topology_VectorBundle_Constructions
case mk.intro.intro.mk.intro.intro.h R : Type u_1 π•œ : Type u_2 B : Type u_3 F : Type u_4 E : B β†’ Type u_5 B' : Type u_6 f✝ : B' β†’ B inst✝¹¹ : TopologicalSpace B' inst✝¹⁰ : TopologicalSpace (TotalSpace F E) inst✝⁹ : NontriviallyNormedField π•œ inst✝⁸ : NormedAddCommGroup F inst✝⁷ : NormedSpace π•œ F inst✝⁢ : TopologicalSpace B inst✝⁡ : (x : B) β†’ AddCommMonoid (E x) inst✝⁴ : (x : B) β†’ Module π•œ (E x) K : Type u_7 inst✝³ : ContinuousMapClass K B' B inst✝² : (x : B) β†’ TopologicalSpace (E x) inst✝¹ : FiberBundle F E inst✝ : VectorBundle π•œ F E f : K e : Trivialization F TotalSpace.proj he : MemTrivializationAtlas e e' : Trivialization F TotalSpace.proj he' : MemTrivializationAtlas e' b : B' hb : f b ∈ e.baseSet ∩ e'.baseSet v : F ⊒ (↑(Trivialization.pullback e' f) (↑(PartialHomeomorph.symm (Trivialization.pullback e f).toPartialHomeomorph) (b, v))).2 = (↑e' { proj := f b, snd := Trivialization.symm e (f b) v }).2 case mk.intro.intro.mk.intro.intro.h.hb R : Type u_1 π•œ : Type u_2 B : Type u_3 F : Type u_4 E : B β†’ Type u_5 B' : Type u_6 f✝ : B' β†’ B inst✝¹¹ : TopologicalSpace B' inst✝¹⁰ : TopologicalSpace (TotalSpace F E) inst✝⁹ : NontriviallyNormedField π•œ inst✝⁸ : NormedAddCommGroup F inst✝⁷ : NormedSpace π•œ F inst✝⁢ : TopologicalSpace B inst✝⁡ : (x : B) β†’ AddCommMonoid (E x) inst✝⁴ : (x : B) β†’ Module π•œ (E x) K : Type u_7 inst✝³ : ContinuousMapClass K B' B inst✝² : (x : B) β†’ TopologicalSpace (E x) inst✝¹ : FiberBundle F E inst✝ : VectorBundle π•œ F E f : K e : Trivialization F TotalSpace.proj he : MemTrivializationAtlas e e' : Trivialization F TotalSpace.proj he' : MemTrivializationAtlas e' b : B' hb : f b ∈ e.baseSet ∩ e'.baseSet v : F ⊒ b ∈ (Trivialization.pullback e f).baseSet ∩ (Trivialization.pullback e' f).baseSet
/- Copyright Β© 2022 NicolΓ² Cavalleri. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: NicolΓ² Cavalleri, SΓ©bastien GouΓ«zel, Heather Macbeth, Floris van Doorn -/ import Mathlib.Topology.FiberBundle.Constructions import Mathlib.Topology.VectorBundle.Basic #align_import topology.vector_bundle.constructions from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" /-! # Standard constructions on vector bundles This file contains several standard constructions on vector bundles: * `Bundle.Trivial.vectorBundle π•œ B F`: the trivial vector bundle with scalar field `π•œ` and model fiber `F` over the base `B` * `VectorBundle.prod`: for vector bundles `E₁` and `Eβ‚‚` with scalar field `π•œ` over a common base, a vector bundle structure on their direct sum `E₁ ×ᡇ Eβ‚‚` (the notation stands for `fun x ↦ E₁ x Γ— Eβ‚‚ x`). * `VectorBundle.pullback`: for a vector bundle `E` over `B`, a vector bundle structure on its pullback `f *α΅– E` by a map `f : B' β†’ B` (the notation is a type synonym for `E ∘ f`). ## Tags Vector bundle, direct sum, pullback -/ noncomputable section open Bundle Set FiberBundle Classical /-! ### The trivial vector bundle -/ namespace Bundle.Trivial variable (π•œ : Type*) (B : Type*) (F : Type*) [NontriviallyNormedField π•œ] [NormedAddCommGroup F] [NormedSpace π•œ F] [TopologicalSpace B] instance trivialization.isLinear : (trivialization B F).IsLinear π•œ where linear _ _ := ⟨fun _ _ => rfl, fun _ _ => rfl⟩ #align bundle.trivial.trivialization.is_linear Bundle.Trivial.trivialization.isLinear variable {π•œ} theorem trivialization.coordChangeL (b : B) : (trivialization B F).coordChangeL π•œ (trivialization B F) b = ContinuousLinearEquiv.refl π•œ F := by ext v rw [Trivialization.coordChangeL_apply'] exacts [rfl, ⟨mem_univ _, mem_univ _⟩] set_option linter.uppercaseLean3 false in #align bundle.trivial.trivialization.coord_changeL Bundle.Trivial.trivialization.coordChangeL variable (π•œ) instance vectorBundle : VectorBundle π•œ F (Bundle.Trivial B F) where trivialization_linear' e he := by rw [eq_trivialization B F e] infer_instance continuousOn_coordChange' e e' he he' := by obtain rfl := eq_trivialization B F e obtain rfl := eq_trivialization B F e' simp only [trivialization.coordChangeL] exact continuous_const.continuousOn #align bundle.trivial.vector_bundle Bundle.Trivial.vectorBundle end Bundle.Trivial /-! ### Direct sum of two vector bundles -/ section variable (π•œ : Type*) {B : Type*} [NontriviallyNormedField π•œ] [TopologicalSpace B] (F₁ : Type*) [NormedAddCommGroup F₁] [NormedSpace π•œ F₁] (E₁ : B β†’ Type*) [TopologicalSpace (TotalSpace F₁ E₁)] (Fβ‚‚ : Type*) [NormedAddCommGroup Fβ‚‚] [NormedSpace π•œ Fβ‚‚] (Eβ‚‚ : B β†’ Type*) [TopologicalSpace (TotalSpace Fβ‚‚ Eβ‚‚)] namespace Trivialization variable {F₁ E₁ Fβ‚‚ Eβ‚‚} variable [βˆ€ x, AddCommMonoid (E₁ x)] [βˆ€ x, Module π•œ (E₁ x)] [βˆ€ x, AddCommMonoid (Eβ‚‚ x)] [βˆ€ x, Module π•œ (Eβ‚‚ x)] (e₁ e₁' : Trivialization F₁ (Ο€ F₁ E₁)) (eβ‚‚ eβ‚‚' : Trivialization Fβ‚‚ (Ο€ Fβ‚‚ Eβ‚‚)) instance prod.isLinear [e₁.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] : (e₁.prod eβ‚‚).IsLinear π•œ where linear := fun _ ⟨h₁, hβ‚‚βŸ© => (((e₁.linear π•œ h₁).mk' _).prodMap ((eβ‚‚.linear π•œ hβ‚‚).mk' _)).isLinear #align trivialization.prod.is_linear Trivialization.prod.isLinear @[simp] theorem coordChangeL_prod [e₁.IsLinear π•œ] [e₁'.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] [eβ‚‚'.IsLinear π•œ] ⦃b⦄ (hb : b ∈ (e₁.prod eβ‚‚).baseSet ∩ (e₁'.prod eβ‚‚').baseSet) : ((e₁.prod eβ‚‚).coordChangeL π•œ (e₁'.prod eβ‚‚') b : F₁ Γ— Fβ‚‚ β†’L[π•œ] F₁ Γ— Fβ‚‚) = (e₁.coordChangeL π•œ e₁' b : F₁ β†’L[π•œ] F₁).prodMap (eβ‚‚.coordChangeL π•œ eβ‚‚' b) := by rw [ContinuousLinearMap.ext_iff, ContinuousLinearMap.coe_prodMap'] rintro ⟨v₁, vβ‚‚βŸ© show (e₁.prod eβ‚‚).coordChangeL π•œ (e₁'.prod eβ‚‚') b (v₁, vβ‚‚) = (e₁.coordChangeL π•œ e₁' b v₁, eβ‚‚.coordChangeL π•œ eβ‚‚' b vβ‚‚) rw [e₁.coordChangeL_apply e₁', eβ‚‚.coordChangeL_apply eβ‚‚', (e₁.prod eβ‚‚).coordChangeL_apply'] exacts [rfl, hb, ⟨hb.1.2, hb.2.2⟩, ⟨hb.1.1, hb.2.1⟩] set_option linter.uppercaseLean3 false in #align trivialization.coord_changeL_prod Trivialization.coordChangeL_prod variable {e₁ eβ‚‚} [βˆ€ x : B, TopologicalSpace (E₁ x)] [βˆ€ x : B, TopologicalSpace (Eβ‚‚ x)] [FiberBundle F₁ E₁] [FiberBundle Fβ‚‚ Eβ‚‚] theorem prod_apply [e₁.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] {x : B} (hx₁ : x ∈ e₁.baseSet) (hxβ‚‚ : x ∈ eβ‚‚.baseSet) (v₁ : E₁ x) (vβ‚‚ : Eβ‚‚ x) : prod e₁ eβ‚‚ ⟨x, (v₁, vβ‚‚)⟩ = ⟨x, e₁.continuousLinearEquivAt π•œ x hx₁ v₁, eβ‚‚.continuousLinearEquivAt π•œ x hxβ‚‚ vβ‚‚βŸ© := rfl #align trivialization.prod_apply Trivialization.prod_apply end Trivialization open Trivialization variable [βˆ€ x, AddCommMonoid (E₁ x)] [βˆ€ x, Module π•œ (E₁ x)] [βˆ€ x, AddCommMonoid (Eβ‚‚ x)] [βˆ€ x, Module π•œ (Eβ‚‚ x)] [βˆ€ x : B, TopologicalSpace (E₁ x)] [βˆ€ x : B, TopologicalSpace (Eβ‚‚ x)] [FiberBundle F₁ E₁] [FiberBundle Fβ‚‚ Eβ‚‚] /-- The product of two vector bundles is a vector bundle. -/ instance VectorBundle.prod [VectorBundle π•œ F₁ E₁] [VectorBundle π•œ Fβ‚‚ Eβ‚‚] : VectorBundle π•œ (F₁ Γ— Fβ‚‚) (E₁ ×ᡇ Eβ‚‚) where trivialization_linear' := by rintro _ ⟨e₁, eβ‚‚, he₁, heβ‚‚, rfl⟩; skip infer_instance continuousOn_coordChange' := by rintro _ _ ⟨e₁, eβ‚‚, he₁, heβ‚‚, rfl⟩ ⟨e₁', eβ‚‚', he₁', heβ‚‚', rfl⟩; skip refine' (((continuousOn_coordChange π•œ e₁ e₁').mono _).prod_mapL π•œ ((continuousOn_coordChange π•œ eβ‚‚ eβ‚‚').mono _)).congr _ <;> dsimp only [baseSet_prod, mfld_simps] Β· mfld_set_tac Β· mfld_set_tac Β· rintro b hb rw [ContinuousLinearMap.ext_iff] rintro ⟨v₁, vβ‚‚βŸ© show (e₁.prod eβ‚‚).coordChangeL π•œ (e₁'.prod eβ‚‚') b (v₁, vβ‚‚) = (e₁.coordChangeL π•œ e₁' b v₁, eβ‚‚.coordChangeL π•œ eβ‚‚' b vβ‚‚) rw [e₁.coordChangeL_apply e₁', eβ‚‚.coordChangeL_apply eβ‚‚', (e₁.prod eβ‚‚).coordChangeL_apply'] exacts [rfl, hb, ⟨hb.1.2, hb.2.2⟩, ⟨hb.1.1, hb.2.1⟩] #align vector_bundle.prod VectorBundle.prod variable {π•œ F₁ E₁ Fβ‚‚ Eβ‚‚} @[simp] -- porting note: changed arguments to make `simpNF` happy: merged `hx₁` and `hxβ‚‚` into `hx` theorem Trivialization.continuousLinearEquivAt_prod {e₁ : Trivialization F₁ (Ο€ F₁ E₁)} {eβ‚‚ : Trivialization Fβ‚‚ (Ο€ Fβ‚‚ Eβ‚‚)} [e₁.IsLinear π•œ] [eβ‚‚.IsLinear π•œ] {x : B} (hx : x ∈ (e₁.prod eβ‚‚).baseSet) : (e₁.prod eβ‚‚).continuousLinearEquivAt π•œ x hx = (e₁.continuousLinearEquivAt π•œ x hx.1).prod (eβ‚‚.continuousLinearEquivAt π•œ x hx.2) := by ext v : 2 obtain ⟨v₁, vβ‚‚βŸ© := v rw [(e₁.prod eβ‚‚).continuousLinearEquivAt_apply π•œ, Trivialization.prod] exact (congr_arg Prod.snd (prod_apply π•œ hx.1 hx.2 v₁ vβ‚‚) : _) #align trivialization.continuous_linear_equiv_at_prod Trivialization.continuousLinearEquivAt_prodβ‚“ end /-! ### Pullbacks of vector bundles -/ section variable (R π•œ : Type*) {B : Type*} (F : Type*) (E : B β†’ Type*) {B' : Type*} (f : B' β†’ B) instance [i : βˆ€ x : B, AddCommMonoid (E x)] (x : B') : AddCommMonoid ((f *α΅– E) x) := i _ instance [Semiring R] [βˆ€ x : B, AddCommMonoid (E x)] [i : βˆ€ x, Module R (E x)] (x : B') : Module R ((f *α΅– E) x) := i _ variable {E F} [TopologicalSpace B'] [TopologicalSpace (TotalSpace F E)] [NontriviallyNormedField π•œ] [NormedAddCommGroup F] [NormedSpace π•œ F] [TopologicalSpace B] [βˆ€ x, AddCommMonoid (E x)] [βˆ€ x, Module π•œ (E x)] {K : Type*} [ContinuousMapClass K B' B] instance Trivialization.pullback_linear (e : Trivialization F (Ο€ F E)) [e.IsLinear π•œ] (f : K) : (@Trivialization.pullback _ _ _ B' _ _ _ _ _ _ _ e f).IsLinear π•œ where linear _ h := e.linear π•œ h #align trivialization.pullback_linear Trivialization.pullback_linear instance VectorBundle.pullback [βˆ€ x, TopologicalSpace (E x)] [FiberBundle F E] [VectorBundle π•œ F E] (f : K) : VectorBundle π•œ F ((f : B' β†’ B) *α΅– E) where trivialization_linear' := by rintro _ ⟨e, he, rfl⟩ infer_instance continuousOn_coordChange' := by rintro _ _ ⟨e, he, rfl⟩ ⟨e', he', rfl⟩ refine' ((continuousOn_coordChange π•œ e e').comp (map_continuous f).continuousOn fun b hb => hb).congr _ rintro b (hb : f b ∈ e.baseSet ∩ e'.baseSet); ext v show ((e.pullback f).coordChangeL π•œ (e'.pullback f) b) v = (e.coordChangeL π•œ e' (f b)) v rw [e.coordChangeL_apply e' hb, (e.pullback f).coordChangeL_apply' _]
exacts [rfl, hb]
instance VectorBundle.pullback [βˆ€ x, TopologicalSpace (E x)] [FiberBundle F E] [VectorBundle π•œ F E] (f : K) : VectorBundle π•œ F ((f : B' β†’ B) *α΅– E) where trivialization_linear' := by rintro _ ⟨e, he, rfl⟩ infer_instance continuousOn_coordChange' := by rintro _ _ ⟨e, he, rfl⟩ ⟨e', he', rfl⟩ refine' ((continuousOn_coordChange π•œ e e').comp (map_continuous f).continuousOn fun b hb => hb).congr _ rintro b (hb : f b ∈ e.baseSet ∩ e'.baseSet); ext v show ((e.pullback f).coordChangeL π•œ (e'.pullback f) b) v = (e.coordChangeL π•œ e' (f b)) v rw [e.coordChangeL_apply e' hb, (e.pullback f).coordChangeL_apply' _]
Mathlib.Topology.VectorBundle.Constructions.184_0.ZrgS90NPsSlDzPQ
instance VectorBundle.pullback [βˆ€ x, TopologicalSpace (E x)] [FiberBundle F E] [VectorBundle π•œ F E] (f : K) : VectorBundle π•œ F ((f : B' β†’ B) *α΅– E) where trivialization_linear'
Mathlib_Topology_VectorBundle_Constructions
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f : M β†’ N p : M β†’ Prop h_mul : βˆ€ (x y : M), p x β†’ p y β†’ f (x * y) ≀ f x * f y hp_mul : βˆ€ (x y : M), p x β†’ p y β†’ p (x * y) g : ΞΉ β†’ M s : Finset ΞΉ hs_nonempty : Finset.Nonempty s hs : βˆ€ i ∈ s, p (g i) ⊒ f (∏ i in s, g i) ≀ ∏ i in s, f (g i)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i) := by
refine' le_trans (Multiset.le_prod_nonempty_of_submultiplicative_on_pred f p h_mul hp_mul _ _ _) _
/-- 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i) := by
Mathlib.Algebra.BigOperators.Order.33_0.ewL52iF1Dz3xeLh
/-- 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i)
Mathlib_Algebra_BigOperators_Order
case refine'_1 ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f : M β†’ N p : M β†’ Prop h_mul : βˆ€ (x y : M), p x β†’ p y β†’ f (x * y) ≀ f x * f y hp_mul : βˆ€ (x y : M), p x β†’ p y β†’ p (x * y) g : ΞΉ β†’ M s : Finset ΞΉ hs_nonempty : Finset.Nonempty s hs : βˆ€ i ∈ s, p (g i) ⊒ Multiset.map (fun i => g i) s.val β‰  βˆ…
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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]
/-- 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_nonempty_of_submultiplicative_on_pred f p h_mul hp_mul _ _ _) _ Β·
Mathlib.Algebra.BigOperators.Order.33_0.ewL52iF1Dz3xeLh
/-- 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i)
Mathlib_Algebra_BigOperators_Order
case refine'_2 ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f : M β†’ N p : M β†’ Prop h_mul : βˆ€ (x y : M), p x β†’ p y β†’ f (x * y) ≀ f x * f y hp_mul : βˆ€ (x y : M), p x β†’ p y β†’ p (x * y) g : ΞΉ β†’ M s : Finset ΞΉ hs_nonempty : Finset.Nonempty s hs : βˆ€ i ∈ s, p (g i) ⊒ βˆ€ a ∈ Multiset.map (fun i => g i) s.val, p a
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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
/-- 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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] Β·
Mathlib.Algebra.BigOperators.Order.33_0.ewL52iF1Dz3xeLh
/-- 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i)
Mathlib_Algebra_BigOperators_Order
case refine'_3 ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f : M β†’ N p : M β†’ Prop h_mul : βˆ€ (x y : M), p x β†’ p y β†’ f (x * y) ≀ f x * f y hp_mul : βˆ€ (x y : M), p x β†’ p y β†’ p (x * y) g : ΞΉ β†’ M s : Finset ΞΉ hs_nonempty : Finset.Nonempty s hs : βˆ€ i ∈ s, p (g i) ⊒ Multiset.prod (Multiset.map f (Multiset.map (fun i => g i) s.val)) ≀ ∏ i in s, f (g i)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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
rw [Multiset.map_map]
/-- 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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
Mathlib.Algebra.BigOperators.Order.33_0.ewL52iF1Dz3xeLh
/-- 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i)
Mathlib_Algebra_BigOperators_Order
case refine'_3 ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f : M β†’ N p : M β†’ Prop h_mul : βˆ€ (x y : M), p x β†’ p y β†’ f (x * y) ≀ f x * f y hp_mul : βˆ€ (x y : M), p x β†’ p y β†’ p (x * y) g : ΞΉ β†’ M s : Finset ΞΉ hs_nonempty : Finset.Nonempty s hs : βˆ€ i ∈ s, p (g i) ⊒ Multiset.prod (Multiset.map (f ∘ fun i => g i) s.val) ≀ ∏ i in s, f (g i)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map]
rfl
/-- 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map]
Mathlib.Algebra.BigOperators.Order.33_0.ewL52iF1Dz3xeLh
/-- 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i)
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f : M β†’ N p : M β†’ Prop h_one : f 1 = 1 h_mul : βˆ€ (x y : M), p x β†’ p y β†’ f (x * y) ≀ f x * f y hp_mul : βˆ€ (x y : M), p x β†’ p y β†’ p (x * y) g : ΞΉ β†’ M s : Finset ΞΉ hs : βˆ€ i ∈ s, p (g i) ⊒ f (∏ i in s, g i) ≀ ∏ i in s, f (g i)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i) := by
rcases eq_empty_or_nonempty s with (rfl | hs_nonempty)
/-- 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i) := by
Mathlib.Algebra.BigOperators.Order.70_0.ewL52iF1Dz3xeLh
/-- 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i)
Mathlib_Algebra_BigOperators_Order
case inl ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f : M β†’ N p : M β†’ Prop h_one : f 1 = 1 h_mul : βˆ€ (x y : M), p x β†’ p y β†’ f (x * y) ≀ f x * f y hp_mul : βˆ€ (x y : M), p x β†’ p y β†’ p (x * y) g : ΞΉ β†’ M hs : βˆ€ i ∈ βˆ…, p (g i) ⊒ f (∏ i in βˆ…, g i) ≀ ∏ i in βˆ…, f (g i)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i) := by rcases eq_empty_or_nonempty s with (rfl | hs_nonempty) Β·
simp [h_one]
/-- 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i) := by rcases eq_empty_or_nonempty s with (rfl | hs_nonempty) Β·
Mathlib.Algebra.BigOperators.Order.70_0.ewL52iF1Dz3xeLh
/-- 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i)
Mathlib_Algebra_BigOperators_Order
case inr ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f : M β†’ N p : M β†’ Prop h_one : f 1 = 1 h_mul : βˆ€ (x y : M), p x β†’ p y β†’ f (x * y) ≀ f x * f y hp_mul : βˆ€ (x y : M), p x β†’ p y β†’ p (x * y) g : ΞΉ β†’ M s : Finset ΞΉ hs : βˆ€ i ∈ s, p (g i) hs_nonempty : Finset.Nonempty s ⊒ f (∏ i in s, g i) ≀ ∏ i in s, f (g i)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i) := by rcases eq_empty_or_nonempty s with (rfl | hs_nonempty) Β· simp [h_one] Β·
Mathlib.Algebra.BigOperators.Order.70_0.ewL52iF1Dz3xeLh
/-- 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in s, f (g i)
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f : M β†’ N h_one : f 1 = 1 h_mul : βˆ€ (x y : M), f (x * y) ≀ f x * f y s : Finset ΞΉ g : ΞΉ β†’ M ⊒ f (∏ i in s, g i) ≀ ∏ i in s, f (g i)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by
refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _
/-- 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by
Mathlib.Algebra.BigOperators.Order.90_0.ewL52iF1Dz3xeLh
/-- 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i)
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f : M β†’ N h_one : f 1 = 1 h_mul : βˆ€ (x y : M), f (x * y) ≀ f x * f y s : Finset ΞΉ g : ΞΉ β†’ M ⊒ Multiset.prod (Multiset.map f (Multiset.map (fun i => g i) s.val)) ≀ ∏ i in s, f (g i)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _
rw [Multiset.map_map]
/-- 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _
Mathlib.Algebra.BigOperators.Order.90_0.ewL52iF1Dz3xeLh
/-- 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i)
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f : M β†’ N h_one : f 1 = 1 h_mul : βˆ€ (x y : M), f (x * y) ≀ f x * f y s : Finset ΞΉ g : ΞΉ β†’ M ⊒ Multiset.prod (Multiset.map (f ∘ fun i => g i) s.val) ≀ ∏ i in s, f (g i)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map]
rfl
/-- 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map]
Mathlib.Algebra.BigOperators.Order.90_0.ewL52iF1Dz3xeLh
/-- 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i)
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s t : Finset ΞΉ h : βˆ€ i ∈ s, 1 ≀ f i ⊒ 1 ≀ ∏ i in s, 1
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by
rw [prod_const_one]
@[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by
Mathlib.Algebra.BigOperators.Order.138_0.ewL52iF1Dz3xeLh
@[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s t : Finset ΞΉ h : βˆ€ i ∈ s, f i ≀ 1 ⊒ ∏ i in s, 1 = 1
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by
rw [prod_const_one]
@[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by
Mathlib.Algebra.BigOperators.Order.150_0.ewL52iF1Dz3xeLh
@[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s t : Finset ΞΉ h : s βŠ† t hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i ⊒ ∏ i in s, f i ≀ ∏ i in t, f i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by
classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h]
@[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by
Mathlib.Algebra.BigOperators.Order.156_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s t : Finset ΞΉ h : s βŠ† t hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i ⊒ ∏ i in s, f i ≀ ∏ i in t, f i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical
calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h]
@[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical
Mathlib.Algebra.BigOperators.Order.156_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s t : Finset ΞΉ h : s βŠ† t hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i ⊒ βˆ€ i ∈ t \ s, 1 ≀ f i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by
simpa only [mem_sdiff, and_imp]
@[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by
Mathlib.Algebra.BigOperators.Order.156_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s t : Finset ΞΉ h : s βŠ† t hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i ⊒ ∏ i in t \ s βˆͺ s, f i = ∏ i in t, f i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by
rw [sdiff_union_of_subset h]
@[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by
Mathlib.Algebra.BigOperators.Order.156_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s t : Finset ΞΉ ⊒ (βˆ€ i ∈ s, 1 ≀ f i) β†’ (∏ i in s, f i = 1 ↔ βˆ€ i ∈ s, f i = 1)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by
classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this]
@[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by
Mathlib.Algebra.BigOperators.Order.181_0.ewL52iF1Dz3xeLh
@[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1)
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s t : Finset ΞΉ ⊒ (βˆ€ i ∈ s, 1 ≀ f i) β†’ (∏ i in s, f i = 1 ↔ βˆ€ i ∈ s, f i = 1)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical
refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_empty _ h), fun _ ↦ rfl⟩) ?_
@[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical
Mathlib.Algebra.BigOperators.Order.181_0.ewL52iF1Dz3xeLh
@[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1)
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s t : Finset ΞΉ ⊒ βˆ€ ⦃a : ι⦄ {s : Finset ΞΉ}, a βˆ‰ s β†’ ((βˆ€ i ∈ s, 1 ≀ f i) β†’ (∏ i in s, f i = 1 ↔ βˆ€ i ∈ s, f i = 1)) β†’ (βˆ€ i ∈ insert a s, 1 ≀ f i) β†’ (∏ i in insert a s, f i = 1 ↔ βˆ€ i ∈ insert a s, f i = 1)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_empty _ h), fun _ ↦ rfl⟩) ?_
intro a s ha ih H
@[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_empty _ h), fun _ ↦ rfl⟩) ?_
Mathlib.Algebra.BigOperators.Order.181_0.ewL52iF1Dz3xeLh
@[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1)
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s✝ t : Finset ΞΉ a : ΞΉ s : Finset ΞΉ ha : a βˆ‰ s ih : (βˆ€ i ∈ s, 1 ≀ f i) β†’ (∏ i in s, f i = 1 ↔ βˆ€ i ∈ s, f i = 1) H : βˆ€ i ∈ insert a s, 1 ≀ f i ⊒ ∏ i in insert a s, f i = 1 ↔ βˆ€ i ∈ insert a s, f i = 1
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_empty _ h), fun _ ↦ rfl⟩) ?_ intro a s ha ih H
have : βˆ€ i ∈ s, 1 ≀ f i := fun _ ↦ H _ ∘ mem_insert_of_mem
@[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_empty _ h), fun _ ↦ rfl⟩) ?_ intro a s ha ih H
Mathlib.Algebra.BigOperators.Order.181_0.ewL52iF1Dz3xeLh
@[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1)
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s✝ t : Finset ΞΉ a : ΞΉ s : Finset ΞΉ ha : a βˆ‰ s ih : (βˆ€ i ∈ s, 1 ≀ f i) β†’ (∏ i in s, f i = 1 ↔ βˆ€ i ∈ s, f i = 1) H : βˆ€ i ∈ insert a s, 1 ≀ f i this : βˆ€ i ∈ s, 1 ≀ f i ⊒ ∏ i in insert a s, f i = 1 ↔ βˆ€ i ∈ insert a s, f i = 1
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this]
@[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_empty _ h), fun _ ↦ rfl⟩) ?_ intro a s ha ih H have : βˆ€ i ∈ s, 1 ≀ f i := fun _ ↦ H _ ∘ mem_insert_of_mem
Mathlib.Algebra.BigOperators.Order.181_0.ewL52iF1Dz3xeLh
@[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1)
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s t : Finset ΞΉ i j : ΞΉ hf : βˆ€ i ∈ s, 1 ≀ f i hi : i ∈ s hj : j ∈ s hne : i β‰  j ⊒ i βˆ‰ {j}
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by
simpa
@[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by
Mathlib.Algebra.BigOperators.Order.211_0.ewL52iF1Dz3xeLh
@[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s t : Finset ΞΉ i j : ΞΉ hf : βˆ€ i ∈ s, 1 ≀ f i hi : i ∈ s hj : j ∈ s hne : i β‰  j ⊒ f i * f j = ∏ k in cons i {j} (_ : i βˆ‰ {j}), f k
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by
rw [prod_cons, prod_singleton]
@[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by
Mathlib.Algebra.BigOperators.Order.211_0.ewL52iF1Dz3xeLh
@[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s t : Finset ΞΉ i j : ΞΉ hf : βˆ€ i ∈ s, 1 ≀ f i hi : i ∈ s hj : j ∈ s hne : i β‰  j ⊒ ∏ k in cons i {j} (_ : i βˆ‰ {j}), f k ≀ ∏ k in s, f k
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in s, f k := by
refine prod_le_prod_of_subset_of_one_le' ?_ fun k hk _ ↦ hf k hk
@[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in s, f k := by
Mathlib.Algebra.BigOperators.Order.211_0.ewL52iF1Dz3xeLh
@[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f g : ΞΉ β†’ N s t : Finset ΞΉ i j : ΞΉ hf : βˆ€ i ∈ s, 1 ≀ f i hi : i ∈ s hj : j ∈ s hne : i β‰  j ⊒ cons i {j} (_ : i βˆ‰ {j}) βŠ† s
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in s, f k := by refine prod_le_prod_of_subset_of_one_le' ?_ fun k hk _ ↦ hf k hk
simp [cons_subset, *]
@[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in s, f k := by refine prod_le_prod_of_subset_of_one_le' ?_ fun k hk _ ↦ hf k hk
Mathlib.Algebra.BigOperators.Order.211_0.ewL52iF1Dz3xeLh
@[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f✝ g : ΞΉ β†’ N s✝ t s : Finset ΞΉ f : ΞΉ β†’ N n : N h : βˆ€ x ∈ s, f x ≀ n ⊒ Finset.prod s f ≀ n ^ card s
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by
refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _
@[to_additive sum_le_card_nsmul] theorem prod_le_pow_card (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by
Mathlib.Algebra.BigOperators.Order.220_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_card_nsmul] theorem prod_le_pow_card (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card
Mathlib_Algebra_BigOperators_Order
case refine'_1 ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f✝ g : ΞΉ β†’ N s✝ t s : Finset ΞΉ f : ΞΉ β†’ N n : N h : βˆ€ x ∈ s, f x ≀ n ⊒ βˆ€ x ∈ Multiset.map f s.val, x ≀ n
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β·
simpa using h
@[to_additive sum_le_card_nsmul] theorem prod_le_pow_card (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β·
Mathlib.Algebra.BigOperators.Order.220_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_card_nsmul] theorem prod_le_pow_card (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card
Mathlib_Algebra_BigOperators_Order
case refine'_2 ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : CommMonoid M inst✝ : OrderedCommMonoid N f✝ g : ΞΉ β†’ N s✝ t s : Finset ΞΉ f : ΞΉ β†’ N n : N h : βˆ€ x ∈ s, f x ≀ n ⊒ n ^ Multiset.card (Multiset.map f s.val) ≀ n ^ card s
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β·
simp
@[to_additive sum_le_card_nsmul] theorem prod_le_pow_card (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β·
Mathlib.Algebra.BigOperators.Order.220_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_card_nsmul] theorem prod_le_pow_card (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G✝ : Type u_6 k : Type u_7 R : Type u_8 G : Type u_9 inst✝ : LinearOrderedAddCommGroup G f : ΞΉ β†’ G s : Finset ΞΉ hf : βˆ€ i ∈ s, 0 ≀ f i ⊒ |βˆ‘ i in s, f i| = βˆ‘ i in s, f i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by
rw [abs_of_nonneg (Finset.sum_nonneg hf)]
theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by
Mathlib.Algebra.BigOperators.Order.271_0.ewL52iF1Dz3xeLh
theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G✝ : Type u_6 k : Type u_7 R : Type u_8 G : Type u_9 inst✝ : LinearOrderedAddCommGroup G f : ΞΉ β†’ G s : Finset ΞΉ hf : βˆ€ (i : ΞΉ), 0 ≀ f i ⊒ |βˆ‘ i in s, f i| = βˆ‘ i in s, f i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by
rw [abs_of_nonneg (Finset.sum_nonneg' hf)]
theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by
Mathlib.Algebra.BigOperators.Order.276_0.ewL52iF1Dz3xeLh
theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : DecidableEq Ξ² f : Ξ± β†’ Ξ² s : Finset Ξ± t : Finset Ξ² Hf : βˆ€ a ∈ s, f a ∈ t n : β„• hn : βˆ€ a ∈ t, card (filter (fun x => f x = a) s) ≀ n ⊒ βˆ‘ _a in t, n = n * card t
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by
simp [mul_comm]
theorem card_le_mul_card_image_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by
Mathlib.Algebra.BigOperators.Order.290_0.ewL52iF1Dz3xeLh
theorem card_le_mul_card_image_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : DecidableEq Ξ² f : Ξ± β†’ Ξ² s : Finset Ξ± t : Finset Ξ² Hf : βˆ€ a ∈ s, f a ∈ t n : β„• hn : βˆ€ a ∈ t, n ≀ card (filter (fun x => f x = a) s) ⊒ n * card t = βˆ‘ _a in t, n
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by
simp [mul_comm]
theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by
Mathlib.Algebra.BigOperators.Order.304_0.ewL52iF1Dz3xeLh
theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : DecidableEq Ξ² f : Ξ± β†’ Ξ² s : Finset Ξ± t : Finset Ξ² Hf : βˆ€ a ∈ s, f a ∈ t n : β„• hn : βˆ€ a ∈ t, n ≀ card (filter (fun x => f x = a) s) ⊒ βˆ‘ a in t, card (filter (fun x => f x = a) s) = card s
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by
rw [← card_eq_sum_card_fiberwise Hf]
theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by
Mathlib.Algebra.BigOperators.Order.304_0.ewL52iF1Dz3xeLh
theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : DecidableEq Ξ± s : Finset Ξ± B : Finset (Finset Ξ±) n : β„• h : βˆ€ a ∈ s, card (filter (fun x => a ∈ x) B) ≀ n ⊒ βˆ‘ t in B, card (s ∩ t) ≀ card s * n
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * n := by
refine' le_trans _ (s.sum_le_card_nsmul _ _ h)
/-- 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * n := by
Mathlib.Algebra.BigOperators.Order.324_0.ewL52iF1Dz3xeLh
/-- 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * n
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : DecidableEq Ξ± s : Finset Ξ± B : Finset (Finset Ξ±) n : β„• h : βˆ€ a ∈ s, card (filter (fun x => a ∈ x) B) ≀ n ⊒ βˆ‘ t in B, card (s ∩ t) ≀ βˆ‘ x in s, card (filter (fun x_1 => x ∈ x_1) B)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * n := by refine' le_trans _ (s.sum_le_card_nsmul _ _ h)
simp_rw [← filter_mem_eq_inter, card_eq_sum_ones, sum_filter]
/-- 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * n := by refine' le_trans _ (s.sum_le_card_nsmul _ _ h)
Mathlib.Algebra.BigOperators.Order.324_0.ewL52iF1Dz3xeLh
/-- 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * n
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : DecidableEq Ξ± s : Finset Ξ± B : Finset (Finset Ξ±) n : β„• h : βˆ€ a ∈ s, card (filter (fun x => a ∈ x) B) ≀ n ⊒ (βˆ‘ x in B, βˆ‘ a in s, if a ∈ x then 1 else 0) ≀ βˆ‘ x in s, βˆ‘ a in B, if x ∈ a then 1 else 0
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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. -/ theorem sum_card_inter_le (h : βˆ€ a ∈ s, (B.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * n := by refine' le_trans _ (s.sum_le_card_nsmul _ _ h) simp_rw [← filter_mem_eq_inter, card_eq_sum_ones, sum_filter]
Mathlib.Algebra.BigOperators.Order.324_0.ewL52iF1Dz3xeLh
/-- 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * n
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : DecidableEq Ξ± s : Finset Ξ± B : Finset (Finset Ξ±) n : β„• inst✝ : Fintype Ξ± h : βˆ€ (a : Ξ±), card (filter (fun x => a ∈ x) B) ≀ n ⊒ βˆ‘ s in B, card s = βˆ‘ s in B, card (univ ∩ s)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by
simp_rw [univ_inter]
/-- 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_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by
Mathlib.Algebra.BigOperators.Order.333_0.ewL52iF1Dz3xeLh
/-- 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_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : DecidableEq Ξ± s : Finset Ξ± B : Finset (Finset Ξ±) n : β„• h : βˆ€ a ∈ s, n ≀ card (filter (fun x => a ∈ x) B) ⊒ card s * n ≀ βˆ‘ t in B, card (s ∩ t)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := by
apply (s.card_nsmul_le_sum _ _ h).trans
/-- 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.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := by
Mathlib.Algebra.BigOperators.Order.342_0.ewL52iF1Dz3xeLh
/-- 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.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : DecidableEq Ξ± s : Finset Ξ± B : Finset (Finset Ξ±) n : β„• h : βˆ€ a ∈ s, n ≀ card (filter (fun x => a ∈ x) B) ⊒ βˆ‘ x in s, card (filter (fun x_1 => x ∈ x_1) B) ≀ βˆ‘ t in B, card (s ∩ t)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := by apply (s.card_nsmul_le_sum _ _ h).trans
simp_rw [← filter_mem_eq_inter, card_eq_sum_ones, sum_filter]
/-- 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.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := by apply (s.card_nsmul_le_sum _ _ h).trans
Mathlib.Algebra.BigOperators.Order.342_0.ewL52iF1Dz3xeLh
/-- 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.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : DecidableEq Ξ± s : Finset Ξ± B : Finset (Finset Ξ±) n : β„• h : βˆ€ a ∈ s, n ≀ card (filter (fun x => a ∈ x) B) ⊒ (βˆ‘ x in s, βˆ‘ a in B, if x ∈ a then 1 else 0) ≀ βˆ‘ x in B, βˆ‘ a in s, if a ∈ x then 1 else 0
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := by apply (s.card_nsmul_le_sum _ _ h).trans simp_rw [← filter_mem_eq_inter, card_eq_sum_ones, sum_filter]
Mathlib.Algebra.BigOperators.Order.342_0.ewL52iF1Dz3xeLh
/-- 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.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : DecidableEq Ξ± s : Finset Ξ± B : Finset (Finset Ξ±) n : β„• inst✝ : Fintype Ξ± h : βˆ€ (a : Ξ±), n ≀ card (filter (fun x => a ∈ x) B) ⊒ βˆ‘ s in B, card (univ ∩ s) = βˆ‘ s in B, card s
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by
simp_rw [univ_inter]
/-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by
Mathlib.Algebra.BigOperators.Order.351_0.ewL52iF1Dz3xeLh
/-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : DecidableEq Ξ± s : Finset Ξ± B : Finset (Finset Ξ±) n : β„• inst✝ : Fintype Ξ± h : βˆ€ (a : Ξ±), card (filter (fun x => a ∈ x) B) = n ⊒ βˆ‘ s in B, card s = Fintype.card Ξ± * n
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by
simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, 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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by
Mathlib.Algebra.BigOperators.Order.367_0.ewL52iF1Dz3xeLh
/-- 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.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : DecidableEq Ξ± s✝ : Finset Ξ± B : Finset (Finset Ξ±) n : β„• s : Finset ΞΉ f : ΞΉ β†’ Finset Ξ± hs : Set.PairwiseDisjoint (↑s) f hf : βˆ€ i ∈ s, Finset.Nonempty (f i) ⊒ card s ≀ card (Finset.biUnion s f)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by
rw [card_biUnion hs, card_eq_sum_ones]
theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by
Mathlib.Algebra.BigOperators.Order.374_0.ewL52iF1Dz3xeLh
theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : DecidableEq Ξ± s✝ : Finset Ξ± B : Finset (Finset Ξ±) n : β„• s : Finset ΞΉ f : ΞΉ β†’ Finset Ξ± hs : Set.PairwiseDisjoint (↑s) f hf : βˆ€ i ∈ s, Finset.Nonempty (f i) ⊒ βˆ‘ x in s, 1 ≀ βˆ‘ u in s, card (f u)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := 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 {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones]
Mathlib.Algebra.BigOperators.Order.374_0.ewL52iF1Dz3xeLh
theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : DecidableEq Ξ± s✝ : Finset Ξ± B : Finset (Finset Ξ±) n : β„• s : Finset ΞΉ f : ΞΉ β†’ Finset Ξ± hs : Set.PairwiseDisjoint (↑s) f ⊒ card s ≀ card (Finset.biUnion s f) + card (filter (fun i => f i = βˆ…) s)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by
rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm]
theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by
Mathlib.Algebra.BigOperators.Order.380_0.ewL52iF1Dz3xeLh
theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : DecidableEq Ξ± s✝ : Finset Ξ± B : Finset (Finset Ξ±) n : β„• s : Finset ΞΉ f : ΞΉ β†’ Finset Ξ± hs : Set.PairwiseDisjoint (↑s) f ⊒ card (filter (fun a => Β¬f a = βˆ…) s) + card (filter (fun i => f i = βˆ…) s) ≀ card (Finset.biUnion s f) + card (filter (fun i => f i = βˆ…) s)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm]
exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _
theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm]
Mathlib.Algebra.BigOperators.Order.380_0.ewL52iF1Dz3xeLh
theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : CanonicallyOrderedCommMonoid M f : ΞΉ β†’ M s t : Finset ΞΉ h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t ⊒ ∏ x in s, f x ≀ ∏ x in t, f x
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by
classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] )
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by
Mathlib.Algebra.BigOperators.Order.423_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : CanonicallyOrderedCommMonoid M f : ΞΉ β†’ M s t : Finset ΞΉ h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t ⊒ ∏ x in s, f x ≀ ∏ x in t, f x
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical
calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] )
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical
Mathlib.Algebra.BigOperators.Order.423_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : CanonicallyOrderedCommMonoid M f : ΞΉ β†’ M s t : Finset ΞΉ h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t ⊒ ∏ x in s, f x = (∏ x in filter (fun x => f x = 1) s, f x) * ∏ x in filter (fun x => f x β‰  1) s, f x
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by
rw [← prod_union, filter_union_filter_neg_eq]
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by
Mathlib.Algebra.BigOperators.Order.423_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : CanonicallyOrderedCommMonoid M f : ΞΉ β†’ M s t : Finset ΞΉ h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t ⊒ Disjoint (filter (fun x => f x = 1) s) (filter (fun x => f x β‰  1) s)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq]
exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq]
Mathlib.Algebra.BigOperators.Order.423_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : CanonicallyOrderedCommMonoid M f : ΞΉ β†’ M s t : Finset ΞΉ h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t ⊒ βˆ€ i ∈ filter (fun x => f x = 1) s, f i ≀ 1
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in t, f x := mul_le_of_le_one_of_le (prod_le_one' <| by
simp only [mem_filter, and_imp]
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in t, f x := mul_le_of_le_one_of_le (prod_le_one' <| by
Mathlib.Algebra.BigOperators.Order.423_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : CanonicallyOrderedCommMonoid M f : ΞΉ β†’ M s t : Finset ΞΉ h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t ⊒ βˆ€ i ∈ s, f i = 1 β†’ f i ≀ 1
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in t, f x := mul_le_of_le_one_of_le (prod_le_one' <| by simp only [mem_filter, and_imp];
Mathlib.Algebra.BigOperators.Order.423_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : CanonicallyOrderedCommMonoid M f : ΞΉ β†’ M s t : Finset ΞΉ h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t ⊒ filter (fun x => f x β‰  1) s βŠ† t
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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]
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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
Mathlib.Algebra.BigOperators.Order.423_0.ewL52iF1Dz3xeLh
@[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ hs : Finset.Nonempty s hlt : βˆ€ i ∈ s, f i < g i ⊒ s.val β‰  βˆ…
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by
aesop
@[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by
Mathlib.Algebra.BigOperators.Order.451_0.ewL52iF1Dz3xeLh
@[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ h : s βŠ† t i : ΞΉ ht : i ∈ t hs : i βˆ‰ s hlt : 1 < f i hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j ⊒ ∏ j in s, f j < ∏ j in t, f j
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by
classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by
Mathlib.Algebra.BigOperators.Order.478_0.ewL52iF1Dz3xeLh
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ h : s βŠ† t i : ΞΉ ht : i ∈ t hs : i βˆ‰ s hlt : 1 < f i hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j ⊒ ∏ j in s, f j < ∏ j in t, f j
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical
calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical
Mathlib.Algebra.BigOperators.Order.478_0.ewL52iF1Dz3xeLh
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ h : s βŠ† t i : ΞΉ ht : i ∈ t hs : i βˆ‰ s hlt : 1 < f i hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j ⊒ ∏ j in s, f j < ∏ j in insert i s, f j
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by
rw [prod_insert hs]
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by
Mathlib.Algebra.BigOperators.Order.478_0.ewL52iF1Dz3xeLh
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ h : s βŠ† t i : ΞΉ ht : i ∈ t hs : i βˆ‰ s hlt : 1 < f i hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j ⊒ ∏ j in s, f j < f i * ∏ x in s, f x
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs]
exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs]
Mathlib.Algebra.BigOperators.Order.478_0.ewL52iF1Dz3xeLh
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ h : s βŠ† t i : ΞΉ ht : i ∈ t hs : i βˆ‰ s hlt : 1 < f i hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j ⊒ ∏ j in insert i s, f j ≀ ∏ j in t, f j
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in t, f j := by
apply prod_le_prod_of_subset_of_one_le'
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in t, f j := by
Mathlib.Algebra.BigOperators.Order.478_0.ewL52iF1Dz3xeLh
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j
Mathlib_Algebra_BigOperators_Order
case h ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ h : s βŠ† t i : ΞΉ ht : i ∈ t hs : i βˆ‰ s hlt : 1 < f i hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j ⊒ insert i s βŠ† t
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in t, f j := by apply prod_le_prod_of_subset_of_one_le' Β·
simp [Finset.insert_subset_iff, h, ht]
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in t, f j := by apply prod_le_prod_of_subset_of_one_le' Β·
Mathlib.Algebra.BigOperators.Order.478_0.ewL52iF1Dz3xeLh
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j
Mathlib_Algebra_BigOperators_Order
case hf ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ h : s βŠ† t i : ΞΉ ht : i ∈ t hs : i βˆ‰ s hlt : 1 < f i hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j ⊒ βˆ€ i_1 ∈ t, i_1 βˆ‰ insert i s β†’ 1 ≀ f i_1
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in t, f j := by apply prod_le_prod_of_subset_of_one_le' Β· simp [Finset.insert_subset_iff, h, ht] Β·
Mathlib.Algebra.BigOperators.Order.478_0.ewL52iF1Dz3xeLh
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j
Mathlib_Algebra_BigOperators_Order
case hf ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ h : s βŠ† t i : ΞΉ ht : i ∈ t hs : i βˆ‰ s hlt : 1 < f i hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j x : ΞΉ hx : x ∈ t h'x : x βˆ‰ insert i s ⊒ 1 ≀ f x
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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
Mathlib.Algebra.BigOperators.Order.478_0.ewL52iF1Dz3xeLh
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j
Mathlib_Algebra_BigOperators_Order
case hf ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ h : s βŠ† t i : ΞΉ ht : i ∈ t hs : i βˆ‰ s hlt : 1 < f i hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j x : ΞΉ hx : x ∈ t h'x : Β¬x = i ∧ x βˆ‰ s ⊒ 1 ≀ f x
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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
Mathlib.Algebra.BigOperators.Order.478_0.ewL52iF1Dz3xeLh
@[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ 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 in {i}, f k
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by
rw [prod_singleton]
@[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by
Mathlib.Algebra.BigOperators.Order.494_0.ewL52iF1Dz3xeLh
@[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ h : βˆ€ i ∈ s, 1 < f i hs : Finset.Nonempty s ⊒ 1 ≀ ∏ i in s, 1
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by
rw [prod_const_one]
@[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by
Mathlib.Algebra.BigOperators.Order.505_0.ewL52iF1Dz3xeLh
@[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ h : βˆ€ i ∈ s, f i < 1 hs : Finset.Nonempty s ⊒ ∏ i in s, 1 ≀ 1
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by
rw [prod_const_one]
@[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by
Mathlib.Algebra.BigOperators.Order.511_0.ewL52iF1Dz3xeLh
@[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f✝ g✝ : ΞΉ β†’ M s t : Finset ΞΉ f g : ΞΉ β†’ M h : βˆ€ i ∈ s, f i ≀ g i ⊒ ∏ i in s, f i = ∏ i in s, g i ↔ βˆ€ i ∈ s, f i = g i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by
classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by
Mathlib.Algebra.BigOperators.Order.529_0.ewL52iF1Dz3xeLh
@[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f✝ g✝ : ΞΉ β†’ M s t : Finset ΞΉ f g : ΞΉ β†’ M h : βˆ€ i ∈ s, f i ≀ g i ⊒ ∏ i in s, f i = ∏ i in s, g i ↔ βˆ€ i ∈ s, f i = g i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical
revert h
@[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical
Mathlib.Algebra.BigOperators.Order.529_0.ewL52iF1Dz3xeLh
@[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f✝ g✝ : ΞΉ β†’ M s t : Finset ΞΉ f g : ΞΉ β†’ M ⊒ (βˆ€ i ∈ s, f i ≀ g i) β†’ (∏ i in s, f i = ∏ i in s, g i ↔ βˆ€ i ∈ s, f i = g i)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h
refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_empty _ h), fun _ ↦ rfl⟩) fun a s ha ih H ↦ ?_
@[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h
Mathlib.Algebra.BigOperators.Order.529_0.ewL52iF1Dz3xeLh
@[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f✝ g✝ : ΞΉ β†’ M s✝ t : Finset ΞΉ f g : ΞΉ β†’ M a : ΞΉ s : Finset ΞΉ ha : a βˆ‰ s ih : (βˆ€ i ∈ s, f i ≀ g i) β†’ (∏ i in s, f i = ∏ i in s, g i ↔ βˆ€ i ∈ s, f i = g i) H : βˆ€ i ∈ insert a s, f i ≀ g i ⊒ ∏ i in insert a s, f i = ∏ i in insert a s, g i ↔ βˆ€ i ∈ insert a s, f i = g i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_empty _ h), fun _ ↦ rfl⟩) fun a s ha ih H ↦ ?_
specialize ih fun i ↦ H i ∘ Finset.mem_insert_of_mem
@[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_empty _ h), fun _ ↦ rfl⟩) fun a s ha ih H ↦ ?_
Mathlib.Algebra.BigOperators.Order.529_0.ewL52iF1Dz3xeLh
@[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f✝ g✝ : ΞΉ β†’ M s✝ t : Finset ΞΉ f g : ΞΉ β†’ M a : ΞΉ s : Finset ΞΉ ha : a βˆ‰ s H : βˆ€ i ∈ insert a s, f i ≀ g i ih : ∏ i in s, f i = ∏ i in s, g i ↔ βˆ€ i ∈ s, f i = g i ⊒ ∏ i in insert a s, f i = ∏ i in insert a s, g i ↔ βˆ€ i ∈ insert a s, f i = g i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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]
@[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_empty _ h), fun _ ↦ rfl⟩) fun a s ha ih H ↦ ?_ specialize ih fun i ↦ H i ∘ Finset.mem_insert_of_mem
Mathlib.Algebra.BigOperators.Order.529_0.ewL52iF1Dz3xeLh
@[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCancelCommMonoid M f✝ g✝ : ΞΉ β†’ M s✝ t : Finset ΞΉ f g : ΞΉ β†’ M a : ΞΉ s : Finset ΞΉ ha : a βˆ‰ s H : βˆ€ i ∈ insert a s, f i ≀ g i ih : ∏ i in s, f i = ∏ i in s, g i ↔ βˆ€ i ∈ s, f i = g i ⊒ f a * ∏ x in s, f x = g a * ∏ x in s, g x ↔ f a = g a ∧ ∏ i in s, f i = ∏ i in s, g i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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]
Mathlib.Algebra.BigOperators.Order.529_0.ewL52iF1Dz3xeLh
@[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ inst✝ : DecidableEq ΞΉ ⊒ ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in t, f i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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]
@[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in t, f i := by
Mathlib.Algebra.BigOperators.Order.546_0.ewL52iF1Dz3xeLh
@[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in t, f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ inst✝ : DecidableEq ΞΉ ⊒ Disjoint (t \ s) (s ∩ t)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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];
Mathlib.Algebra.BigOperators.Order.546_0.ewL52iF1Dz3xeLh
@[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in t, f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ inst✝ : DecidableEq ΞΉ ⊒ ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in t, f i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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]
@[to_additive] lemma prod_sdiff_lt_prod_sdiff : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in t, f i := by
Mathlib.Algebra.BigOperators.Order.552_0.ewL52iF1Dz3xeLh
@[to_additive] lemma prod_sdiff_lt_prod_sdiff : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in t, f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝¹ : OrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ inst✝ : DecidableEq ΞΉ ⊒ Disjoint (t \ s) (s ∩ t)
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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
@[to_additive] lemma prod_sdiff_lt_prod_sdiff : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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];
Mathlib.Algebra.BigOperators.Order.552_0.ewL52iF1Dz3xeLh
@[to_additive] lemma prod_sdiff_lt_prod_sdiff : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in t, f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : LinearOrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ Hlt : ∏ i in s, f i < ∏ i in s, g i ⊒ βˆƒ i ∈ s, f i < g i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by
contrapose! Hlt with Hle
@[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by
Mathlib.Algebra.BigOperators.Order.564_0.ewL52iF1Dz3xeLh
@[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : LinearOrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ Hle : βˆ€ i ∈ s, g i ≀ f i ⊒ ∏ i in s, g i ≀ ∏ i in s, f i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle
exact prod_le_prod' Hle
@[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle
Mathlib.Algebra.BigOperators.Order.564_0.ewL52iF1Dz3xeLh
@[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : LinearOrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ hs : Finset.Nonempty s Hle : ∏ i in s, f i ≀ ∏ i in s, g i ⊒ βˆƒ i ∈ s, f i ≀ g i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by
contrapose! Hle with Hlt
@[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by
Mathlib.Algebra.BigOperators.Order.571_0.ewL52iF1Dz3xeLh
@[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : LinearOrderedCancelCommMonoid M f g : ΞΉ β†’ M s t : Finset ΞΉ hs : Finset.Nonempty s Hlt : βˆ€ i ∈ s, g i < f i ⊒ ∏ i in s, g i < ∏ i in s, f i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt
exact prod_lt_prod_of_nonempty' hs Hlt
@[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt
Mathlib.Algebra.BigOperators.Order.571_0.ewL52iF1Dz3xeLh
@[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : LinearOrderedCancelCommMonoid M f✝ g : ΞΉ β†’ M s t : Finset ΞΉ f : ΞΉ β†’ M h₁ : ∏ i in s, f i = 1 hβ‚‚ : βˆƒ i ∈ s, f i β‰  1 ⊒ βˆƒ i ∈ s, 1 < f i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by
contrapose! h₁
@[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by
Mathlib.Algebra.BigOperators.Order.579_0.ewL52iF1Dz3xeLh
@[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : LinearOrderedCancelCommMonoid M f✝ g : ΞΉ β†’ M s t : Finset ΞΉ f : ΞΉ β†’ M hβ‚‚ : βˆƒ i ∈ s, f i β‰  1 h₁ : βˆ€ i ∈ s, f i ≀ 1 ⊒ ∏ i in s, f i β‰  1
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁
obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚
@[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁
Mathlib.Algebra.BigOperators.Order.579_0.ewL52iF1Dz3xeLh
@[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i
Mathlib_Algebra_BigOperators_Order
case intro.intro ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : LinearOrderedCancelCommMonoid M f✝ g : ΞΉ β†’ M s t : Finset ΞΉ f : ΞΉ β†’ M h₁ : βˆ€ i ∈ s, f i ≀ 1 i : ΞΉ m : i ∈ s i_ne : f i β‰  1 ⊒ ∏ i in s, f i β‰  1
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚
apply ne_of_lt
@[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚
Mathlib.Algebra.BigOperators.Order.579_0.ewL52iF1Dz3xeLh
@[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i
Mathlib_Algebra_BigOperators_Order
case intro.intro.h ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : LinearOrderedCancelCommMonoid M f✝ g : ΞΉ β†’ M s t : Finset ΞΉ f : ΞΉ β†’ M h₁ : βˆ€ i ∈ s, f i ≀ 1 i : ΞΉ m : i ∈ s i_ne : f i β‰  1 ⊒ ∏ i in s, f i < 1
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚ apply ne_of_lt
calc ∏ j in s, f j < ∏ j in s, 1 := prod_lt_prod' h₁ ⟨i, m, (h₁ i m).lt_of_ne i_ne⟩ _ = 1 := prod_const_one
@[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚ apply ne_of_lt
Mathlib.Algebra.BigOperators.Order.579_0.ewL52iF1Dz3xeLh
@[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCommSemiring R f g : ΞΉ β†’ R s t : Finset ΞΉ h0 : βˆ€ i ∈ s, 0 ≀ f i h1 : βˆ€ i ∈ s, f i ≀ g i ⊒ ∏ i in s, f i ≀ ∏ i in s, g i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚ apply ne_of_lt calc ∏ j in s, f j < ∏ j in s, 1 := prod_lt_prod' h₁ ⟨i, m, (h₁ i m).lt_of_ne i_ne⟩ _ = 1 := prod_const_one #align finset.exists_one_lt_of_prod_one_of_exists_ne_one' Finset.exists_one_lt_of_prod_one_of_exists_ne_one' #align finset.exists_pos_of_sum_zero_of_exists_nonzero Finset.exists_pos_of_sum_zero_of_exists_nonzero end LinearOrderedCancelCommMonoid section OrderedCommSemiring variable [OrderedCommSemiring R] {f g : ΞΉ β†’ R} {s t : Finset ΞΉ} open Classical -- this is also true for an ordered commutative multiplicative monoid with zero theorem prod_nonneg (h0 : βˆ€ i ∈ s, 0 ≀ f i) : 0 ≀ ∏ i in s, f i := prod_induction f (fun i ↦ 0 ≀ i) (fun _ _ ha hb ↦ mul_nonneg ha hb) zero_le_one h0 #align finset.prod_nonneg Finset.prod_nonneg /-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by
induction' s using Finset.induction with a s has ih h
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by
Mathlib.Algebra.BigOperators.Order.604_0.ewL52iF1Dz3xeLh
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i
Mathlib_Algebra_BigOperators_Order
case empty ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCommSemiring R f g : ΞΉ β†’ R s t : Finset ΞΉ h0 : βˆ€ i ∈ βˆ…, 0 ≀ f i h1 : βˆ€ i ∈ βˆ…, f i ≀ g i ⊒ ∏ i in βˆ…, f i ≀ ∏ i in βˆ…, g i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚ apply ne_of_lt calc ∏ j in s, f j < ∏ j in s, 1 := prod_lt_prod' h₁ ⟨i, m, (h₁ i m).lt_of_ne i_ne⟩ _ = 1 := prod_const_one #align finset.exists_one_lt_of_prod_one_of_exists_ne_one' Finset.exists_one_lt_of_prod_one_of_exists_ne_one' #align finset.exists_pos_of_sum_zero_of_exists_nonzero Finset.exists_pos_of_sum_zero_of_exists_nonzero end LinearOrderedCancelCommMonoid section OrderedCommSemiring variable [OrderedCommSemiring R] {f g : ΞΉ β†’ R} {s t : Finset ΞΉ} open Classical -- this is also true for an ordered commutative multiplicative monoid with zero theorem prod_nonneg (h0 : βˆ€ i ∈ s, 0 ≀ f i) : 0 ≀ ∏ i in s, f i := prod_induction f (fun i ↦ 0 ≀ i) (fun _ _ ha hb ↦ mul_nonneg ha hb) zero_le_one h0 #align finset.prod_nonneg Finset.prod_nonneg /-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β·
simp
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β·
Mathlib.Algebra.BigOperators.Order.604_0.ewL52iF1Dz3xeLh
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i
Mathlib_Algebra_BigOperators_Order
case insert ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCommSemiring R f g : ΞΉ β†’ R s✝ t : Finset ΞΉ a : ΞΉ s : Finset ΞΉ has : a βˆ‰ s ih : (βˆ€ i ∈ s, 0 ≀ f i) β†’ (βˆ€ i ∈ s, f i ≀ g i) β†’ ∏ i in s, f i ≀ ∏ i in s, g i h0 : βˆ€ i ∈ insert a s, 0 ≀ f i h1 : βˆ€ i ∈ insert a s, f i ≀ g i ⊒ ∏ i in insert a s, f i ≀ ∏ i in insert a s, g i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚ apply ne_of_lt calc ∏ j in s, f j < ∏ j in s, 1 := prod_lt_prod' h₁ ⟨i, m, (h₁ i m).lt_of_ne i_ne⟩ _ = 1 := prod_const_one #align finset.exists_one_lt_of_prod_one_of_exists_ne_one' Finset.exists_one_lt_of_prod_one_of_exists_ne_one' #align finset.exists_pos_of_sum_zero_of_exists_nonzero Finset.exists_pos_of_sum_zero_of_exists_nonzero end LinearOrderedCancelCommMonoid section OrderedCommSemiring variable [OrderedCommSemiring R] {f g : ΞΉ β†’ R} {s t : Finset ΞΉ} open Classical -- this is also true for an ordered commutative multiplicative monoid with zero theorem prod_nonneg (h0 : βˆ€ i ∈ s, 0 ≀ f i) : 0 ≀ ∏ i in s, f i := prod_induction f (fun i ↦ 0 ≀ i) (fun _ _ ha hb ↦ mul_nonneg ha hb) zero_le_one h0 #align finset.prod_nonneg Finset.prod_nonneg /-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β·
simp only [prod_insert has]
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β·
Mathlib.Algebra.BigOperators.Order.604_0.ewL52iF1Dz3xeLh
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i
Mathlib_Algebra_BigOperators_Order
case insert ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCommSemiring R f g : ΞΉ β†’ R s✝ t : Finset ΞΉ a : ΞΉ s : Finset ΞΉ has : a βˆ‰ s ih : (βˆ€ i ∈ s, 0 ≀ f i) β†’ (βˆ€ i ∈ s, f i ≀ g i) β†’ ∏ i in s, f i ≀ ∏ i in s, g i h0 : βˆ€ i ∈ insert a s, 0 ≀ f i h1 : βˆ€ i ∈ insert a s, f i ≀ g i ⊒ f a * ∏ i in s, f i ≀ g a * ∏ i in s, g i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚ apply ne_of_lt calc ∏ j in s, f j < ∏ j in s, 1 := prod_lt_prod' h₁ ⟨i, m, (h₁ i m).lt_of_ne i_ne⟩ _ = 1 := prod_const_one #align finset.exists_one_lt_of_prod_one_of_exists_ne_one' Finset.exists_one_lt_of_prod_one_of_exists_ne_one' #align finset.exists_pos_of_sum_zero_of_exists_nonzero Finset.exists_pos_of_sum_zero_of_exists_nonzero end LinearOrderedCancelCommMonoid section OrderedCommSemiring variable [OrderedCommSemiring R] {f g : ΞΉ β†’ R} {s t : Finset ΞΉ} open Classical -- this is also true for an ordered commutative multiplicative monoid with zero theorem prod_nonneg (h0 : βˆ€ i ∈ s, 0 ≀ f i) : 0 ≀ ∏ i in s, f i := prod_induction f (fun i ↦ 0 ≀ i) (fun _ _ ha hb ↦ mul_nonneg ha hb) zero_le_one h0 #align finset.prod_nonneg Finset.prod_nonneg /-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has]
apply mul_le_mul
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has]
Mathlib.Algebra.BigOperators.Order.604_0.ewL52iF1Dz3xeLh
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i
Mathlib_Algebra_BigOperators_Order
case insert.h₁ ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCommSemiring R f g : ΞΉ β†’ R s✝ t : Finset ΞΉ a : ΞΉ s : Finset ΞΉ has : a βˆ‰ s ih : (βˆ€ i ∈ s, 0 ≀ f i) β†’ (βˆ€ i ∈ s, f i ≀ g i) β†’ ∏ i in s, f i ≀ ∏ i in s, g i h0 : βˆ€ i ∈ insert a s, 0 ≀ f i h1 : βˆ€ i ∈ insert a s, f i ≀ g i ⊒ f a ≀ g a
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚ apply ne_of_lt calc ∏ j in s, f j < ∏ j in s, 1 := prod_lt_prod' h₁ ⟨i, m, (h₁ i m).lt_of_ne i_ne⟩ _ = 1 := prod_const_one #align finset.exists_one_lt_of_prod_one_of_exists_ne_one' Finset.exists_one_lt_of_prod_one_of_exists_ne_one' #align finset.exists_pos_of_sum_zero_of_exists_nonzero Finset.exists_pos_of_sum_zero_of_exists_nonzero end LinearOrderedCancelCommMonoid section OrderedCommSemiring variable [OrderedCommSemiring R] {f g : ΞΉ β†’ R} {s t : Finset ΞΉ} open Classical -- this is also true for an ordered commutative multiplicative monoid with zero theorem prod_nonneg (h0 : βˆ€ i ∈ s, 0 ≀ f i) : 0 ≀ ∏ i in s, f i := prod_induction f (fun i ↦ 0 ≀ i) (fun _ _ ha hb ↦ mul_nonneg ha hb) zero_le_one h0 #align finset.prod_nonneg Finset.prod_nonneg /-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has] apply mul_le_mul Β·
exact h1 a (mem_insert_self a s)
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has] apply mul_le_mul Β·
Mathlib.Algebra.BigOperators.Order.604_0.ewL52iF1Dz3xeLh
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i
Mathlib_Algebra_BigOperators_Order
case insert.hβ‚‚ ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCommSemiring R f g : ΞΉ β†’ R s✝ t : Finset ΞΉ a : ΞΉ s : Finset ΞΉ has : a βˆ‰ s ih : (βˆ€ i ∈ s, 0 ≀ f i) β†’ (βˆ€ i ∈ s, f i ≀ g i) β†’ ∏ i in s, f i ≀ ∏ i in s, g i h0 : βˆ€ i ∈ insert a s, 0 ≀ f i h1 : βˆ€ i ∈ insert a s, f i ≀ g i ⊒ ∏ i in s, f i ≀ ∏ i in s, g i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚ apply ne_of_lt calc ∏ j in s, f j < ∏ j in s, 1 := prod_lt_prod' h₁ ⟨i, m, (h₁ i m).lt_of_ne i_ne⟩ _ = 1 := prod_const_one #align finset.exists_one_lt_of_prod_one_of_exists_ne_one' Finset.exists_one_lt_of_prod_one_of_exists_ne_one' #align finset.exists_pos_of_sum_zero_of_exists_nonzero Finset.exists_pos_of_sum_zero_of_exists_nonzero end LinearOrderedCancelCommMonoid section OrderedCommSemiring variable [OrderedCommSemiring R] {f g : ΞΉ β†’ R} {s t : Finset ΞΉ} open Classical -- this is also true for an ordered commutative multiplicative monoid with zero theorem prod_nonneg (h0 : βˆ€ i ∈ s, 0 ≀ f i) : 0 ≀ ∏ i in s, f i := prod_induction f (fun i ↦ 0 ≀ i) (fun _ _ ha hb ↦ mul_nonneg ha hb) zero_le_one h0 #align finset.prod_nonneg Finset.prod_nonneg /-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has] apply mul_le_mul Β· exact h1 a (mem_insert_self a s) Β·
refine ih (fun x H ↦ h0 _ ?_) (fun x H ↦ h1 _ ?_)
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has] apply mul_le_mul Β· exact h1 a (mem_insert_self a s) Β·
Mathlib.Algebra.BigOperators.Order.604_0.ewL52iF1Dz3xeLh
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i
Mathlib_Algebra_BigOperators_Order
case insert.hβ‚‚.refine_1 ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCommSemiring R f g : ΞΉ β†’ R s✝ t : Finset ΞΉ a : ΞΉ s : Finset ΞΉ has : a βˆ‰ s ih : (βˆ€ i ∈ s, 0 ≀ f i) β†’ (βˆ€ i ∈ s, f i ≀ g i) β†’ ∏ i in s, f i ≀ ∏ i in s, g i h0 : βˆ€ i ∈ insert a s, 0 ≀ f i h1 : βˆ€ i ∈ insert a s, f i ≀ g i x : ΞΉ H : x ∈ s ⊒ x ∈ insert a s
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚ apply ne_of_lt calc ∏ j in s, f j < ∏ j in s, 1 := prod_lt_prod' h₁ ⟨i, m, (h₁ i m).lt_of_ne i_ne⟩ _ = 1 := prod_const_one #align finset.exists_one_lt_of_prod_one_of_exists_ne_one' Finset.exists_one_lt_of_prod_one_of_exists_ne_one' #align finset.exists_pos_of_sum_zero_of_exists_nonzero Finset.exists_pos_of_sum_zero_of_exists_nonzero end LinearOrderedCancelCommMonoid section OrderedCommSemiring variable [OrderedCommSemiring R] {f g : ΞΉ β†’ R} {s t : Finset ΞΉ} open Classical -- this is also true for an ordered commutative multiplicative monoid with zero theorem prod_nonneg (h0 : βˆ€ i ∈ s, 0 ≀ f i) : 0 ≀ ∏ i in s, f i := prod_induction f (fun i ↦ 0 ≀ i) (fun _ _ ha hb ↦ mul_nonneg ha hb) zero_le_one h0 #align finset.prod_nonneg Finset.prod_nonneg /-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has] apply mul_le_mul Β· exact h1 a (mem_insert_self a s) Β· refine ih (fun x H ↦ h0 _ ?_) (fun x H ↦ h1 _ ?_) <;>
exact mem_insert_of_mem H
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has] apply mul_le_mul Β· exact h1 a (mem_insert_self a s) Β· refine ih (fun x H ↦ h0 _ ?_) (fun x H ↦ h1 _ ?_) <;>
Mathlib.Algebra.BigOperators.Order.604_0.ewL52iF1Dz3xeLh
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i
Mathlib_Algebra_BigOperators_Order
case insert.hβ‚‚.refine_2 ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCommSemiring R f g : ΞΉ β†’ R s✝ t : Finset ΞΉ a : ΞΉ s : Finset ΞΉ has : a βˆ‰ s ih : (βˆ€ i ∈ s, 0 ≀ f i) β†’ (βˆ€ i ∈ s, f i ≀ g i) β†’ ∏ i in s, f i ≀ ∏ i in s, g i h0 : βˆ€ i ∈ insert a s, 0 ≀ f i h1 : βˆ€ i ∈ insert a s, f i ≀ g i x : ΞΉ H : x ∈ s ⊒ x ∈ insert a s
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚ apply ne_of_lt calc ∏ j in s, f j < ∏ j in s, 1 := prod_lt_prod' h₁ ⟨i, m, (h₁ i m).lt_of_ne i_ne⟩ _ = 1 := prod_const_one #align finset.exists_one_lt_of_prod_one_of_exists_ne_one' Finset.exists_one_lt_of_prod_one_of_exists_ne_one' #align finset.exists_pos_of_sum_zero_of_exists_nonzero Finset.exists_pos_of_sum_zero_of_exists_nonzero end LinearOrderedCancelCommMonoid section OrderedCommSemiring variable [OrderedCommSemiring R] {f g : ΞΉ β†’ R} {s t : Finset ΞΉ} open Classical -- this is also true for an ordered commutative multiplicative monoid with zero theorem prod_nonneg (h0 : βˆ€ i ∈ s, 0 ≀ f i) : 0 ≀ ∏ i in s, f i := prod_induction f (fun i ↦ 0 ≀ i) (fun _ _ ha hb ↦ mul_nonneg ha hb) zero_le_one h0 #align finset.prod_nonneg Finset.prod_nonneg /-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has] apply mul_le_mul Β· exact h1 a (mem_insert_self a s) Β· refine ih (fun x H ↦ h0 _ ?_) (fun x H ↦ h1 _ ?_) <;>
exact mem_insert_of_mem H
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has] apply mul_le_mul Β· exact h1 a (mem_insert_self a s) Β· refine ih (fun x H ↦ h0 _ ?_) (fun x H ↦ h1 _ ?_) <;>
Mathlib.Algebra.BigOperators.Order.604_0.ewL52iF1Dz3xeLh
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i
Mathlib_Algebra_BigOperators_Order
case insert.c0 ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCommSemiring R f g : ΞΉ β†’ R s✝ t : Finset ΞΉ a : ΞΉ s : Finset ΞΉ has : a βˆ‰ s ih : (βˆ€ i ∈ s, 0 ≀ f i) β†’ (βˆ€ i ∈ s, f i ≀ g i) β†’ ∏ i in s, f i ≀ ∏ i in s, g i h0 : βˆ€ i ∈ insert a s, 0 ≀ f i h1 : βˆ€ i ∈ insert a s, f i ≀ g i ⊒ 0 ≀ ∏ i in s, f i
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚ apply ne_of_lt calc ∏ j in s, f j < ∏ j in s, 1 := prod_lt_prod' h₁ ⟨i, m, (h₁ i m).lt_of_ne i_ne⟩ _ = 1 := prod_const_one #align finset.exists_one_lt_of_prod_one_of_exists_ne_one' Finset.exists_one_lt_of_prod_one_of_exists_ne_one' #align finset.exists_pos_of_sum_zero_of_exists_nonzero Finset.exists_pos_of_sum_zero_of_exists_nonzero end LinearOrderedCancelCommMonoid section OrderedCommSemiring variable [OrderedCommSemiring R] {f g : ΞΉ β†’ R} {s t : Finset ΞΉ} open Classical -- this is also true for an ordered commutative multiplicative monoid with zero theorem prod_nonneg (h0 : βˆ€ i ∈ s, 0 ≀ f i) : 0 ≀ ∏ i in s, f i := prod_induction f (fun i ↦ 0 ≀ i) (fun _ _ ha hb ↦ mul_nonneg ha hb) zero_le_one h0 #align finset.prod_nonneg Finset.prod_nonneg /-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has] apply mul_le_mul Β· exact h1 a (mem_insert_self a s) Β· refine ih (fun x H ↦ h0 _ ?_) (fun x H ↦ h1 _ ?_) <;> exact mem_insert_of_mem H Β·
apply prod_nonneg fun x H ↦ h0 x (mem_insert_of_mem H)
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has] apply mul_le_mul Β· exact h1 a (mem_insert_self a s) Β· refine ih (fun x H ↦ h0 _ ?_) (fun x H ↦ h1 _ ?_) <;> exact mem_insert_of_mem H Β·
Mathlib.Algebra.BigOperators.Order.604_0.ewL52iF1Dz3xeLh
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i
Mathlib_Algebra_BigOperators_Order
case insert.b0 ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCommSemiring R f g : ΞΉ β†’ R s✝ t : Finset ΞΉ a : ΞΉ s : Finset ΞΉ has : a βˆ‰ s ih : (βˆ€ i ∈ s, 0 ≀ f i) β†’ (βˆ€ i ∈ s, f i ≀ g i) β†’ ∏ i in s, f i ≀ ∏ i in s, g i h0 : βˆ€ i ∈ insert a s, 0 ≀ f i h1 : βˆ€ i ∈ insert a s, f i ≀ g i ⊒ 0 ≀ g a
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚ apply ne_of_lt calc ∏ j in s, f j < ∏ j in s, 1 := prod_lt_prod' h₁ ⟨i, m, (h₁ i m).lt_of_ne i_ne⟩ _ = 1 := prod_const_one #align finset.exists_one_lt_of_prod_one_of_exists_ne_one' Finset.exists_one_lt_of_prod_one_of_exists_ne_one' #align finset.exists_pos_of_sum_zero_of_exists_nonzero Finset.exists_pos_of_sum_zero_of_exists_nonzero end LinearOrderedCancelCommMonoid section OrderedCommSemiring variable [OrderedCommSemiring R] {f g : ΞΉ β†’ R} {s t : Finset ΞΉ} open Classical -- this is also true for an ordered commutative multiplicative monoid with zero theorem prod_nonneg (h0 : βˆ€ i ∈ s, 0 ≀ f i) : 0 ≀ ∏ i in s, f i := prod_induction f (fun i ↦ 0 ≀ i) (fun _ _ ha hb ↦ mul_nonneg ha hb) zero_le_one h0 #align finset.prod_nonneg Finset.prod_nonneg /-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has] apply mul_le_mul Β· exact h1 a (mem_insert_self a s) Β· refine ih (fun x H ↦ h0 _ ?_) (fun x H ↦ h1 _ ?_) <;> exact mem_insert_of_mem H Β· apply prod_nonneg fun x H ↦ h0 x (mem_insert_of_mem H) Β·
apply le_trans (h0 a (mem_insert_self a s)) (h1 a (mem_insert_self a s))
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has] apply mul_le_mul Β· exact h1 a (mem_insert_self a s) Β· refine ih (fun x H ↦ h0 _ ?_) (fun x H ↦ h1 _ ?_) <;> exact mem_insert_of_mem H Β· apply prod_nonneg fun x H ↦ h0 x (mem_insert_of_mem H) Β·
Mathlib.Algebra.BigOperators.Order.604_0.ewL52iF1Dz3xeLh
/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i
Mathlib_Algebra_BigOperators_Order
ΞΉ : Type u_1 Ξ± : Type u_2 Ξ² : Type u_3 M : Type u_4 N : Type u_5 G : Type u_6 k : Type u_7 R : Type u_8 inst✝ : OrderedCommSemiring R f g : ΞΉ β†’ R s t : Finset ΞΉ h0 : βˆ€ i ∈ s, 0 ≀ f i h1 : βˆ€ i ∈ s, f i ≀ 1 ⊒ ∏ i in s, f i ≀ 1
/- 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 -/ import Mathlib.Algebra.Order.AbsoluteValue import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.BigOperators.Basic import Mathlib.Data.Fintype.Card import Mathlib.Tactic.GCongr.Core #align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Results about big operators with values in an ordered algebraic structure. Mostly monotonicity results for the `∏` and `βˆ‘` operations. -/ open Function open BigOperators variable {ΞΉ Ξ± Ξ² M N G k R : Type*} namespace Finset section OrderedCommMonoid variable [CommMonoid M] [OrderedCommMonoid 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 in s, g x) ≀ ∏ x in s, f (g x)`. -/ @[to_additive le_sum_nonempty_of_subadditive_on_pred] theorem le_prod_nonempty_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 rw [Multiset.map_map] rfl #align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred #align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_nonempty_of_subadditive] theorem le_prod_nonempty_of_submultiplicative (f : M β†’ N) (h_mul : βˆ€ x y, f (x * y) ≀ f x * f y) {s : Finset ΞΉ} (hs : s.Nonempty) (g : ΞΉ β†’ M) : f (∏ i in s, g i) ≀ ∏ i in 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 #align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative #align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive_on_pred] theorem le_prod_of_submultiplicative_on_pred (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 in s, g i) ≀ ∏ i in 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 #align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred #align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred /-- 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 in s, g x) ≀ βˆ‘ x in 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 in s, g i) ≀ ∏ i in s, f (g i)`. -/ @[to_additive le_sum_of_subadditive] theorem le_prod_of_submultiplicative (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 in s, g i) ≀ ∏ i in s, f (g i) := by refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _ rw [Multiset.map_map] rfl #align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative #align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive /-- 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 in s, g i) ≀ βˆ‘ i in s, f (g i)`. -/ add_decl_doc le_sum_of_subadditive 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 in s, f i ≀ ∏ i in s, g i`. -/ @[to_additive sum_le_sum] theorem prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := Multiset.prod_map_le_prod_map f g h #align finset.prod_le_prod' Finset.prod_le_prod' #align finset.sum_le_sum Finset.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 in s, f i ≀ βˆ‘ i in s, g i`. -/ add_decl_doc sum_le_sum /-- 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 `s.prod f ≀ s.prod g`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_le_sum] theorem _root_.GCongr.prod_le_prod' (h : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod' h /-- 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 `s.sum f ≀ s.sum g`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_le_sum @[to_additive sum_nonneg] theorem one_le_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) : 1 ≀ ∏ i in s, f i := le_trans (by rw [prod_const_one]) (prod_le_prod' h) #align finset.one_le_prod' Finset.one_le_prod' #align finset.sum_nonneg Finset.sum_nonneg @[to_additive Finset.sum_nonneg'] theorem one_le_prod'' (h : βˆ€ i : ΞΉ, 1 ≀ f i) : 1 ≀ ∏ i : ΞΉ in s, f i := Finset.one_le_prod' fun i _ ↦ h i #align finset.one_le_prod'' Finset.one_le_prod'' #align finset.sum_nonneg' Finset.sum_nonneg' @[to_additive sum_nonpos] theorem prod_le_one' (h : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := (prod_le_prod' h).trans_eq (by rw [prod_const_one]) #align finset.prod_le_one' Finset.prod_le_one' #align finset.sum_nonpos Finset.sum_nonpos @[to_additive sum_le_sum_of_subset_of_nonneg] theorem prod_le_prod_of_subset_of_one_le' (h : s βŠ† t) (hf : βˆ€ i ∈ t, i βˆ‰ s β†’ 1 ≀ f i) : ∏ i in s, f i ≀ ∏ i in t, f i := by classical calc ∏ i in s, f i ≀ (∏ i in t \ s, f i) * ∏ i in s, f i := le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp] _ = ∏ i in t \ s βˆͺ s, f i := (prod_union sdiff_disjoint).symm _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h] #align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le' #align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg @[to_additive sum_mono_set_of_nonneg] theorem prod_mono_set_of_one_le' (hf : βˆ€ x, 1 ≀ f x) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x #align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le' #align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg @[to_additive sum_le_univ_sum_of_nonneg] theorem prod_le_univ_prod_of_one_le' [Fintype ΞΉ] {s : Finset ΞΉ} (w : βˆ€ x, 1 ≀ f x) : ∏ x in s, f x ≀ ∏ x, f x := prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a #align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le' #align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg -- Porting Note: TODO -- The two next lemmas give the same lemma in additive version @[to_additive sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_one_le' : (βˆ€ i ∈ s, 1 ≀ f i) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := by classical refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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' (H _ <| mem_insert_self _ _) (one_le_prod' this), forall_mem_insert, ih this] #align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le' #align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg @[to_additive existing sum_eq_zero_iff_of_nonneg] theorem prod_eq_one_iff_of_le_one' : (βˆ€ i ∈ s, f i ≀ 1) β†’ ((∏ i in s, f i) = 1 ↔ βˆ€ i ∈ s, f i = 1) := @prod_eq_one_iff_of_one_le' _ Nα΅’α΅ˆ _ _ _ #align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one' -- Porting note: there is no align for the additive version since it aligns to the -- same one as the previous lemma @[to_additive single_le_sum] theorem single_le_prod' (hf : βˆ€ i ∈ s, 1 ≀ f i) {a} (h : a ∈ s) : f a ≀ ∏ x in s, f x := calc f a = ∏ i in {a}, f i := (prod_singleton _ _).symm _ ≀ ∏ i in s, f i := prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi #align finset.single_le_prod' Finset.single_le_prod' #align finset.single_le_sum Finset.single_le_sum @[to_additive] lemma mul_le_prod {i j : ΞΉ} (hf : βˆ€ i ∈ s, 1 ≀ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i β‰  j) : f i * f j ≀ ∏ k in s, f k := calc f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton] _ ≀ ∏ k in 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 (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, f x ≀ n) : s.prod f ≀ n ^ s.card := by refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _ Β· simpa using h Β· simp #align finset.prod_le_pow_card Finset.prod_le_pow_card #align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod (s : Finset ΞΉ) (f : ΞΉ β†’ N) (n : N) (h : βˆ€ x ∈ s, n ≀ f x) : n ^ s.card ≀ s.prod f := @Finset.prod_le_pow_card _ Nα΅’α΅ˆ _ _ _ _ h #align finset.pow_card_le_prod Finset.pow_card_le_prod #align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum theorem card_biUnion_le_card_mul [DecidableEq Ξ²] (s : Finset ΞΉ) (f : ΞΉ β†’ Finset Ξ²) (n : β„•) (h : βˆ€ a ∈ s, (f a).card ≀ n) : (s.biUnion f).card ≀ s.card * n := card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h #align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul variable {ΞΉ' : Type*} [DecidableEq ΞΉ'] -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg] theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, (1 : N) ≀ ∏ x in s.filter fun x ↦ g x = y, f x) : (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ x in s, f x := calc (∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x) ≀ ∏ y in t βˆͺ s.image g, ∏ x in s.filter fun x ↦ g x = y, f x := prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y _ ↦ h y _ = ∏ x in s, f x := prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _ #align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' #align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg -- Porting note: Mathport warning: expanding binder collection (y Β«expr βˆ‰ Β» t) @[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ΞΉ'} {g : ΞΉ β†’ ΞΉ'} {f : ΞΉ β†’ N} (h : βˆ€ y βˆ‰ t, ∏ x in s.filter fun x ↦ g x = y, f x ≀ 1) : ∏ x in s, f x ≀ ∏ y in t, ∏ x in s.filter fun x ↦ g x = y, f x := @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nα΅’α΅ˆ _ _ _ _ _ _ _ h #align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' #align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos end OrderedCommMonoid theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ΞΉ β†’ G) (s : Finset ΞΉ) : |βˆ‘ i in s, f i| ≀ βˆ‘ i in s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f #align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i ∈ s, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg hf)] #align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ΞΉ β†’ G} {s : Finset ΞΉ} (hf : βˆ€ i, 0 ≀ f i) : |βˆ‘ i : ΞΉ in s, f i| = βˆ‘ i : ΞΉ in s, f i := by rw [abs_of_nonneg (Finset.sum_nonneg' hf)] #align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg' theorem abs_prod {R : Type*} [LinearOrderedCommRing R] {f : ΞΉ β†’ R} {s : Finset ΞΉ} : |∏ x in s, f x| = ∏ x in s, |f x| := map_prod absHom _ _ #align finset.abs_prod Finset.abs_prod 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 : βˆ€ a ∈ t, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * t.card := calc s.card = βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := card_eq_sum_card_fiberwise Hf _ ≀ βˆ‘ _a in t, n := sum_le_sum hn _ = _ := by simp [mul_comm] #align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to theorem card_le_mul_card_image {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, (s.filter fun x ↦ f x = a).card ≀ n) : s.card ≀ n * (s.image f).card := card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.card_le_mul_card_image Finset.card_le_mul_card_image theorem mul_card_image_le_card_of_maps_to {f : Ξ± β†’ Ξ²} {s : Finset Ξ±} {t : Finset Ξ²} (Hf : βˆ€ a ∈ s, f a ∈ t) (n : β„•) (hn : βˆ€ a ∈ t, n ≀ (s.filter fun x ↦ f x = a).card) : n * t.card ≀ s.card := calc n * t.card = βˆ‘ _a in t, n := by simp [mul_comm] _ ≀ βˆ‘ a in t, (s.filter fun x ↦ f x = a).card := sum_le_sum hn _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf] #align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to theorem mul_card_image_le_card {f : Ξ± β†’ Ξ²} (s : Finset Ξ±) (n : β„•) (hn : βˆ€ a ∈ s.image f, n ≀ (s.filter fun x ↦ f x = a).card) : n * (s.image f).card ≀ s.card := mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn #align finset.mul_card_image_le_card Finset.mul_card_image_le_card 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.filter (a ∈ Β·)).card ≀ n) : (βˆ‘ t in B, (s ∩ t).card) ≀ s.card * 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 #align finset.sum_card_inter_le Finset.sum_card_inter_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. -/ theorem sum_card_le [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card ≀ n) : βˆ‘ s in B, s.card ≀ Fintype.card Ξ± * n := calc βˆ‘ s in B, s.card = βˆ‘ s in B, (univ ∩ s).card := by simp_rw [univ_inter] _ ≀ Fintype.card Ξ± * n := sum_card_inter_le fun a _ ↦ h a #align finset.sum_card_le Finset.sum_card_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_inter (h : βˆ€ a ∈ s, n ≀ (B.filter (a ∈ Β·)).card) : s.card * n ≀ βˆ‘ t in B, (s ∩ t).card := 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 #align finset.le_sum_card_inter Finset.le_sum_card_inter /-- 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.filter (a ∈ Β·)).card) : Fintype.card Ξ± * n ≀ βˆ‘ s in B, s.card := calc Fintype.card Ξ± * n ≀ βˆ‘ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ ↦ h a _ = βˆ‘ s in B, s.card := by simp_rw [univ_inter] #align finset.le_sum_card Finset.le_sum_card /-- 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.filter (a ∈ Β·)).card = n) : (βˆ‘ t in B, (s ∩ t).card) = s.card * n := (sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge) #align finset.sum_card_inter Finset.sum_card_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 [Fintype Ξ±] (h : βˆ€ a, (B.filter (a ∈ Β·)).card = n) : βˆ‘ s in B, s.card = Fintype.card Ξ± * n := by simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter] #align finset.sum_card Finset.sum_card theorem card_le_card_biUnion {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) (hf : βˆ€ i ∈ s, (f i).Nonempty) : s.card ≀ (s.biUnion f).card := by rw [card_biUnion hs, card_eq_sum_ones] exact sum_le_sum fun i hi ↦ (hf i hi).card_pos #align finset.card_le_card_bUnion Finset.card_le_card_biUnion theorem card_le_card_biUnion_add_card_fiber {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + (s.filter fun i ↦ f i = βˆ…).card := by rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i ↦ f i = βˆ…, add_comm] exact add_le_add_right ((card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦ nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <| card_le_of_subset <| biUnion_subset_biUnion_of_subset_left _ <| filter_subset _ _) _ #align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_biUnion_add_card_fiber theorem card_le_card_biUnion_add_one {s : Finset ΞΉ} {f : ΞΉ β†’ Finset Ξ±} (hf : Injective f) (hs : (s : Set ΞΉ).PairwiseDisjoint f) : s.card ≀ (s.biUnion f).card + 1 := (card_le_card_biUnion_add_card_fiber hs).trans <| add_le_add_left (card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _ #align finset.card_le_card_bUnion_add_one Finset.card_le_card_biUnion_add_one end DoubleCounting section CanonicallyOrderedCommMonoid variable [CanonicallyOrderedCommMonoid M] {f : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive (attr := simp) sum_eq_zero_iff] theorem prod_eq_one_iff' : ∏ x in s, f x = 1 ↔ βˆ€ x ∈ s, f x = 1 := prod_eq_one_iff_of_one_le' fun x _ ↦ one_le (f x) #align finset.prod_eq_one_iff' Finset.prod_eq_one_iff' #align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff @[to_additive sum_le_sum_of_subset] theorem prod_le_prod_of_subset' (h : s βŠ† t) : ∏ x in s, f x ≀ ∏ x in t, f x := prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le _ #align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset' #align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset @[to_additive sum_mono_set] theorem prod_mono_set' (f : ΞΉ β†’ M) : Monotone fun s ↦ ∏ x in s, f x := fun _ _ hs ↦ prod_le_prod_of_subset' hs #align finset.prod_mono_set' Finset.prod_mono_set' #align finset.sum_mono_set Finset.sum_mono_set @[to_additive sum_le_sum_of_ne_zero] theorem prod_le_prod_of_ne_one' (h : βˆ€ x ∈ s, f x β‰  1 β†’ x ∈ t) : ∏ x in s, f x ≀ ∏ x in t, f x := by classical calc ∏ x in s, f x = (∏ x in s.filter fun x ↦ f x = 1, f x) * ∏ x in s.filter fun x ↦ f x β‰  1, f x := by rw [← prod_union, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h _ ≀ ∏ x in 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] ) #align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one' #align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero end CanonicallyOrderedCommMonoid section OrderedCancelCommMonoid variable [OrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive sum_lt_sum] theorem prod_lt_prod' (hle : βˆ€ i ∈ s, f i ≀ g i) (hlt : βˆƒ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod' hle hlt #align finset.prod_lt_prod' Finset.prod_lt_prod' #align finset.sum_lt_sum Finset.sum_lt_sum @[to_additive sum_lt_sum_of_nonempty] theorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (hlt : βˆ€ i ∈ s, f i < g i) : ∏ i in s, f i < ∏ i in s, g i := Multiset.prod_lt_prod_of_nonempty' (by aesop) hlt #align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty' #align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_lt_prod_of_nonempty'`, convenient for the `gcongr` tactic. -/ @[to_additive (attr := gcongr) GCongr.sum_lt_sum_of_nonempty] theorem _root_.GCongr.prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : βˆ€ i ∈ s, f i < g i) : s.prod f < s.prod g := s.prod_lt_prod_of_nonempty' hs Hlt /-- 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`. This is a variant (beta-reduced) version of the standard lemma `Finset.sum_lt_sum_of_nonempty`, convenient for the `gcongr` tactic. -/ add_decl_doc GCongr.sum_lt_sum_of_nonempty -- Porting note: TODO -- calc indentation @[to_additive sum_lt_sum_of_subset] theorem prod_lt_prod_of_subset' (h : s βŠ† t) {i : ΞΉ} (ht : i ∈ t) (hs : i βˆ‰ s) (hlt : 1 < f i) (hle : βˆ€ j ∈ t, j βˆ‰ s β†’ 1 ≀ f j) : ∏ j in s, f j < ∏ j in t, f j := by classical calc ∏ j in s, f j < ∏ j in insert i s, f j := by rw [prod_insert hs] exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt _ ≀ ∏ j in 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 #align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset' #align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset @[to_additive single_lt_sum] theorem single_lt_prod' {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 in s, f k := calc f i = ∏ k in {i}, f k := by rw [prod_singleton] _ < ∏ k in 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) #align finset.single_lt_prod' Finset.single_lt_prod' #align finset.single_lt_sum Finset.single_lt_sum @[to_additive sum_pos] theorem one_lt_prod (h : βˆ€ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i := lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h #align finset.one_lt_prod Finset.one_lt_prod #align finset.sum_pos Finset.sum_pos @[to_additive] theorem prod_lt_one (h : βˆ€ i ∈ s, f i < 1) (hs : s.Nonempty) : ∏ i in s, f i < 1 := (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one]) #align finset.prod_lt_one Finset.prod_lt_one #align finset.sum_neg Finset.sum_neg @[to_additive sum_pos'] theorem one_lt_prod' (h : βˆ€ i ∈ s, 1 ≀ f i) (hs : βˆƒ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i := prod_const_one.symm.trans_lt <| prod_lt_prod' h hs #align finset.one_lt_prod' Finset.one_lt_prod' #align finset.sum_pos' Finset.sum_pos' @[to_additive] theorem prod_lt_one' (h : βˆ€ i ∈ s, f i ≀ 1) (hs : βˆƒ i ∈ s, f i < 1) : ∏ i in s, f i < 1 := prod_const_one.le.trans_lt' <| prod_lt_prod' h hs #align finset.prod_lt_one' Finset.prod_lt_one' #align finset.sum_neg' Finset.sum_neg' @[to_additive] theorem prod_eq_prod_iff_of_le {f g : ΞΉ β†’ M} (h : βˆ€ i ∈ s, f i ≀ g i) : ((∏ i in s, f i) = ∏ i in s, g i) ↔ βˆ€ i ∈ s, f i = g i := by classical revert h refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_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) #align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le #align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le variable [DecidableEq ΞΉ] @[to_additive] lemma prod_sdiff_le_prod_sdiff : ∏ i in s \ t, f i ≀ ∏ i in t \ s, f i ↔ ∏ i in s, f i ≀ ∏ i in 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 : ∏ i in s \ t, f i < ∏ i in t \ s, f i ↔ ∏ i in s, f i < ∏ i in 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 [LinearOrderedCancelCommMonoid M] {f g : ΞΉ β†’ M} {s t : Finset ΞΉ} @[to_additive exists_lt_of_sum_lt] theorem exists_lt_of_prod_lt' (Hlt : ∏ i in s, f i < ∏ i in s, g i) : βˆƒ i ∈ s, f i < g i := by contrapose! Hlt with Hle exact prod_le_prod' Hle #align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt' #align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt @[to_additive exists_le_of_sum_le] theorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : ∏ i in s, f i ≀ ∏ i in s, g i) : βˆƒ i ∈ s, f i ≀ g i := by contrapose! Hle with Hlt exact prod_lt_prod_of_nonempty' hs Hlt #align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le' #align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le @[to_additive exists_pos_of_sum_zero_of_exists_nonzero] theorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ΞΉ β†’ M) (h₁ : ∏ i in s, f i = 1) (hβ‚‚ : βˆƒ i ∈ s, f i β‰  1) : βˆƒ i ∈ s, 1 < f i := by contrapose! h₁ obtain ⟨i, m, i_ne⟩ : βˆƒ i ∈ s, f i β‰  1 := hβ‚‚ apply ne_of_lt calc ∏ j in s, f j < ∏ j in s, 1 := prod_lt_prod' h₁ ⟨i, m, (h₁ i m).lt_of_ne i_ne⟩ _ = 1 := prod_const_one #align finset.exists_one_lt_of_prod_one_of_exists_ne_one' Finset.exists_one_lt_of_prod_one_of_exists_ne_one' #align finset.exists_pos_of_sum_zero_of_exists_nonzero Finset.exists_pos_of_sum_zero_of_exists_nonzero end LinearOrderedCancelCommMonoid section OrderedCommSemiring variable [OrderedCommSemiring R] {f g : ΞΉ β†’ R} {s t : Finset ΞΉ} open Classical -- this is also true for an ordered commutative multiplicative monoid with zero theorem prod_nonneg (h0 : βˆ€ i ∈ s, 0 ≀ f i) : 0 ≀ ∏ i in s, f i := prod_induction f (fun i ↦ 0 ≀ i) (fun _ _ ha hb ↦ mul_nonneg ha hb) zero_le_one h0 #align finset.prod_nonneg Finset.prod_nonneg /-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. See also `Finset.prod_le_prod'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : ∏ i in s, f i ≀ ∏ i in s, g i := by induction' s using Finset.induction with a s has ih h Β· simp Β· simp only [prod_insert has] apply mul_le_mul Β· exact h1 a (mem_insert_self a s) Β· refine ih (fun x H ↦ h0 _ ?_) (fun x H ↦ h1 _ ?_) <;> exact mem_insert_of_mem H Β· apply prod_nonneg fun x H ↦ h0 x (mem_insert_of_mem H) Β· apply le_trans (h0 a (mem_insert_self a s)) (h1 a (mem_insert_self a s)) #align finset.prod_le_prod Finset.prod_le_prod /-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the product of `f i` is less than or equal to the product of `g i`. This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod`, convenient for the `gcongr` tactic. -/ @[gcongr] theorem _root_.GCongr.prod_le_prod (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ g i) : s.prod f ≀ s.prod g := s.prod_le_prod h0 h1 /-- If each `f i`, `i ∈ s` belongs to `[0, 1]`, then their product is less than or equal to one. See also `Finset.prod_le_one'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_one (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := by
convert ← prod_le_prod h0 h1
/-- If each `f i`, `i ∈ s` belongs to `[0, 1]`, then their product is less than or equal to one. See also `Finset.prod_le_one'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_one (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1 := by
Mathlib.Algebra.BigOperators.Order.629_0.ewL52iF1Dz3xeLh
/-- If each `f i`, `i ∈ s` belongs to `[0, 1]`, then their product is less than or equal to one. See also `Finset.prod_le_one'` for the case of an ordered commutative multiplicative monoid. -/ theorem prod_le_one (h0 : βˆ€ i ∈ s, 0 ≀ f i) (h1 : βˆ€ i ∈ s, f i ≀ 1) : ∏ i in s, f i ≀ 1
Mathlib_Algebra_BigOperators_Order