|
| 1 | +/- |
| 2 | +Copyright (c) 2024 Yaël Dillies, Andrew Yang. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Yaël Dillies, Andrew Yang |
| 5 | +-/ |
| 6 | +import Mathlib.Algebra.Order.Group.OrderIso |
| 7 | +import Mathlib.Algebra.Order.Monoid.Canonical.Defs |
| 8 | +import Mathlib.Algebra.Order.Monoid.Unbundled.MinMax |
| 9 | +import Mathlib.Algebra.Order.Monoid.Unbundled.Pow |
| 10 | +import Mathlib.Algebra.Order.Monoid.Unbundled.WithTop |
| 11 | +import Mathlib.Data.Finset.Lattice.Fold |
| 12 | + |
| 13 | +/-! |
| 14 | +# `Finset.sup` in a group |
| 15 | +-/ |
| 16 | + |
| 17 | +assert_not_exists MonoidWithZero |
| 18 | + |
| 19 | +namespace Finset |
| 20 | +variable {ι κ M G : Type*} |
| 21 | + |
| 22 | +lemma fold_max_add [LinearOrder M] [Add M] [AddRightMono M] (s : Finset ι) (a : WithBot M) |
| 23 | + (f : ι → M) : s.fold max ⊥ (fun i ↦ ↑(f i) + a) = s.fold max ⊥ ((↑) ∘ f) + a := by |
| 24 | + classical |
| 25 | + induction' s using Finset.induction_on with a s _ ih <;> simp [*, max_add_add_right] |
| 26 | + |
| 27 | +@[to_additive nsmul_inf'] |
| 28 | +lemma inf'_pow [LinearOrder M] [Monoid M] [MulLeftMono M] [MulRightMono M] (s : Finset ι) |
| 29 | + (f : ι → M) (n : ℕ) (hs) : s.inf' hs f ^ n = s.inf' hs fun a ↦ f a ^ n := |
| 30 | + map_finset_inf' (OrderHom.mk _ <| pow_left_mono n) hs _ |
| 31 | + |
| 32 | +@[to_additive nsmul_sup'] |
| 33 | +lemma sup'_pow [LinearOrder M] [Monoid M] [MulLeftMono M] [MulRightMono M] (s : Finset ι) |
| 34 | + (f : ι → M) (n : ℕ) (hs) : s.sup' hs f ^ n = s.sup' hs fun a ↦ f a ^ n := |
| 35 | + map_finset_sup' (OrderHom.mk _ <| pow_left_mono n) hs _ |
| 36 | + |
| 37 | +section Group |
| 38 | +variable [Group G] [LinearOrder G] |
| 39 | + |
| 40 | +@[to_additive "Also see `Finset.sup'_add'` that works for canonically ordered monoids."] |
| 41 | +lemma sup'_mul [MulRightMono G] (s : Finset ι) (f : ι → G) (a : G) (hs) : |
| 42 | + s.sup' hs f * a = s.sup' hs fun i ↦ f i * a := map_finset_sup' (OrderIso.mulRight a) hs f |
| 43 | + |
| 44 | +set_option linter.docPrime false in |
| 45 | +@[to_additive "Also see `Finset.add_sup''` that works for canonically ordered monoids."] |
| 46 | +lemma mul_sup' [MulLeftMono G] (s : Finset ι) (f : ι → G) (a : G) (hs) : |
| 47 | + a * s.sup' hs f = s.sup' hs fun i ↦ a * f i := map_finset_sup' (OrderIso.mulLeft a) hs f |
| 48 | + |
| 49 | +end Group |
| 50 | + |
| 51 | +section CanonicallyLinearOrderedAddCommMonoid |
| 52 | +variable [CanonicallyLinearOrderedAddCommMonoid M] [Sub M] [AddLeftReflectLE M] [OrderedSub M] |
| 53 | + {s : Finset ι} {t : Finset κ} |
| 54 | + |
| 55 | +/-- Also see `Finset.sup'_add` that works for ordered groups. -/ |
| 56 | +lemma sup'_add' (s : Finset ι) (f : ι → M) (a : M) (hs : s.Nonempty) : |
| 57 | + s.sup' hs f + a = s.sup' hs fun i ↦ f i + a := by |
| 58 | + apply le_antisymm |
| 59 | + · apply add_le_of_le_tsub_right_of_le |
| 60 | + · exact Finset.le_sup'_of_le _ hs.choose_spec le_add_self |
| 61 | + · exact Finset.sup'_le _ _ fun i hi ↦ le_tsub_of_add_le_right (Finset.le_sup' (f · + a) hi) |
| 62 | + · exact Finset.sup'_le _ _ fun i hi ↦ add_le_add_right (Finset.le_sup' _ hi) _ |
| 63 | + |
| 64 | +/-- Also see `Finset.add_sup'` that works for ordered groups. -/ |
| 65 | +lemma add_sup'' (hs : s.Nonempty) (f : ι → M) (a : M) : |
| 66 | + a + s.sup' hs f = s.sup' hs fun i ↦ a + f i := by simp_rw [add_comm a, Finset.sup'_add'] |
| 67 | + |
| 68 | +protected lemma sup_add (hs : s.Nonempty) (f : ι → M) (a : M) : |
| 69 | + s.sup f + a = s.sup fun i ↦ f i + a := by |
| 70 | + rw [← Finset.sup'_eq_sup hs, ← Finset.sup'_eq_sup hs, sup'_add'] |
| 71 | + |
| 72 | +protected lemma add_sup (hs : s.Nonempty) (f : ι → M) (a : M) : |
| 73 | + a + s.sup f = s.sup fun i ↦ a + f i := by |
| 74 | + rw [← Finset.sup'_eq_sup hs, ← Finset.sup'_eq_sup hs, add_sup''] |
| 75 | + |
| 76 | +lemma sup_add_sup (hs : s.Nonempty) (ht : t.Nonempty) (f : ι → M) (g : κ → M) : |
| 77 | + s.sup f + t.sup g = (s ×ˢ t).sup fun ij ↦ f ij.1 + g ij.2 := by |
| 78 | + simp only [Finset.sup_add hs, Finset.add_sup ht, Finset.sup_product_left] |
| 79 | + |
| 80 | +end CanonicallyLinearOrderedAddCommMonoid |
| 81 | +end Finset |
0 commit comments