Skip to content

Commit df5da3e

Browse files
committed
feat(Algebra/Order/BigOperators/Expect): add lemmas and strict variants (#33662)
### Summary - Combine `le_expect_nonempty_of_subadditive` and `le_expect_of_subadditive` into a single lemma `le_expect_of_subadditive`. The extra assumptions `(hs : s.Nonempty)` and `(h_zero : m 0 = 0)` are unnecessary (since `m 0 = 0` follows from `h_div`). This requires a small downstream update to `Mathlib/Analysis/RCLike/Basic.lean` (`norm_expect_le`). - Add strict-inequality variants: `expect_lt_expect`, `expect_lt`, `lt_expect`. - Add existence lemmas: `exists_le_of_expect_le_expect`, `exists_le_of_le_expect`, `exists_le_of_expect_le`, and `exists_lt_of_expect_lt_expect`.
1 parent 405fef5 commit df5da3e

1 file changed

Lines changed: 40 additions & 2 deletions

File tree

Mathlib/Algebra/Order/BigOperators/Expect.lean

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,26 @@ end OrderedAddCommMonoid
110110

111111
section OrderedCancelAddCommMonoid
112112
variable [AddCommMonoid α] [PartialOrder α] [IsOrderedCancelAddMonoid α] [Module ℚ≥0 α]
113-
{s : Finset ι} {f : ι → α}
113+
{a : α} {s : Finset ι} {f g : ι → α}
114114
section PosSMulStrictMono
115115
variable [PosSMulStrictMono ℚ≥0 α]
116116

117+
lemma expect_lt_expect (hle : ∀ i ∈ s, f i ≤ g i) (hlt : ∃ i ∈ s, f i < g i) :
118+
𝔼 i ∈ s, f i < 𝔼 i ∈ s, g i := by
119+
apply smul_lt_smul_of_pos_left (sum_lt_sum hle hlt)
120+
rw [inv_pos, Nat.cast_pos, card_pos]
121+
exact hlt.imp (fun _ => And.left)
122+
123+
lemma expect_lt (hle : ∀ x ∈ s, f x ≤ a) (hlt : ∃ x ∈ s, f x < a) :
124+
𝔼 i ∈ s, f i < a := by
125+
rw [← expect_const (hlt.imp (fun _ => And.left)) a]
126+
exact expect_lt_expect hle hlt
127+
128+
lemma lt_expect (hle : ∀ x ∈ s, a ≤ f x) (hlt : ∃ x ∈ s, a < f x) :
129+
a < 𝔼 i ∈ s, f i := by
130+
rw [← expect_const (hlt.imp (fun _ => And.left)) a]
131+
exact expect_lt_expect hle hlt
132+
117133
lemma expect_pos (hf : ∀ i ∈ s, 0 < f i) (hs : s.Nonempty) : 0 < 𝔼 i ∈ s, f i :=
118134
smul_pos (inv_pos.2 <| mod_cast hs.card_pos) <| sum_pos hf hs
119135

@@ -123,7 +139,11 @@ end OrderedCancelAddCommMonoid
123139
section LinearOrderedAddCommMonoid
124140
variable [AddCommMonoid α] [LinearOrder α] [IsOrderedAddMonoid α] [Module ℚ≥0 α]
125141
[PosSMulMono ℚ≥0 α] {s : Finset ι}
126-
{f : ι → α} {a : α}
142+
{f g : ι → α} {a : α}
143+
144+
lemma exists_lt_of_expect_lt_expect (h : 𝔼 i ∈ s, g i < 𝔼 i ∈ s, f i) :
145+
∃ x ∈ s, g x < f x := by
146+
contrapose! h; exact expect_le_expect h
127147

128148
lemma exists_lt_of_lt_expect (hs : s.Nonempty) (h : a < 𝔼 i ∈ s, f i) : ∃ x ∈ s, a < f x := by
129149
contrapose! h; exact expect_le hs h
@@ -133,6 +153,24 @@ lemma exists_lt_of_expect_lt (hs : s.Nonempty) (h : 𝔼 i ∈ s, f i < a) : ∃
133153

134154
end LinearOrderedAddCommMonoid
135155

156+
section LinearOrderedCancelAddMonoid
157+
variable [AddCommMonoid α] [LinearOrder α] [IsOrderedCancelAddMonoid α] [Module ℚ≥0 α]
158+
[PosSMulStrictMono ℚ≥0 α] {a : α} {s : Finset ι} {f g : ι → α}
159+
160+
lemma exists_le_of_expect_le_expect (hs : s.Nonempty) (h : 𝔼 i ∈ s, g i ≤ 𝔼 i ∈ s, f i) :
161+
∃ x ∈ s, g x ≤ f x := by
162+
obtain ⟨_, hx⟩ := hs
163+
contrapose! h
164+
exact expect_lt_expect (fun _ hx ↦ le_of_lt (h _ hx)) ⟨_, ⟨hx, h _ hx⟩⟩
165+
166+
lemma exists_le_of_le_expect (hs : s.Nonempty) (h : a ≤ 𝔼 i ∈ s, f i) : ∃ x ∈ s, a ≤ f x :=
167+
exists_le_of_expect_le_expect hs (by rwa [expect_const hs _])
168+
169+
lemma exists_le_of_expect_le (hs : s.Nonempty) (h : 𝔼 i ∈ s, f i ≤ a) : ∃ x ∈ s, f x ≤ a :=
170+
exists_le_of_expect_le_expect hs (by rwa [expect_const hs _])
171+
172+
end LinearOrderedCancelAddMonoid
173+
136174
section LinearOrderedAddCommGroup
137175
variable [AddCommGroup α] [LinearOrder α] [IsOrderedAddMonoid α] [Module ℚ≥0 α] [PosSMulMono ℚ≥0 α]
138176

0 commit comments

Comments
 (0)