Skip to content

Commit 2fc191a

Browse files
committed
feat: @[gcongr] for indicator_le_indicator_of_subset (#31847)
This PR tags `indicator_le_indicator_of_subset` and `indicator_le_indicator_apply_of_subset` with `gcongr`, and uses this to golf some proofs. It may be possible to improve `gcongr` in the future so that we only need to tag one of the two lemmas with `gcongr`.
1 parent 22da866 commit 2fc191a

File tree

11 files changed

+26
-26
lines changed

11 files changed

+26
-26
lines changed

Mathlib/Algebra/Order/Archimedean/IndicatorCard.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ lemma infinite_iff_tendsto_sum_indicator_atTop {R : Type*}
5353
obtain ⟨n', hn'⟩ := exists_lt_nsmul h n
5454
obtain ⟨t, t_s, t_card⟩ := hs.exists_subset_card_eq n'
5555
obtain ⟨m, hm⟩ := t.bddAbove
56-
refine ⟨m + 1, hn'.le.trans ?_⟩
57-
apply (sum_le_sum fun i _ ↦ (indicator_le_indicator_of_subset t_s (fun _ ↦ h.le)) i).trans_eq'
56+
use m + 1
57+
grw [hn', ← t_s]
5858
have h : t ⊆ Finset.range (m + 1) := by
5959
intro i i_t
6060
rw [Finset.mem_range]

Mathlib/Algebra/Order/Group/Indicator.lean

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ lemma mulIndicator_le_mulIndicator (h : f a ≤ g a) : mulIndicator s f a ≤ mu
117117
lemma mulIndicator_mono (h : f ≤ g) : s.mulIndicator f ≤ s.mulIndicator g :=
118118
fun _ ↦ mulIndicator_le_mulIndicator (h _)
119119

120-
@[to_additive]
120+
@[to_additive (attr := gcongr)]
121121
lemma mulIndicator_le_mulIndicator_apply_of_subset (h : s ⊆ t) (hf : 1 ≤ f a) :
122122
mulIndicator s f a ≤ mulIndicator t f a :=
123123
mulIndicator_apply_le'
124124
(fun ha ↦ le_mulIndicator_apply (fun _ ↦ le_rfl) fun hat ↦ (hat <| h ha).elim) fun _ ↦
125125
one_le_mulIndicator_apply fun _ ↦ hf
126126

127-
@[to_additive]
127+
@[to_additive (attr := gcongr)]
128128
lemma mulIndicator_le_mulIndicator_of_subset (h : s ⊆ t) (hf : 1 ≤ f) :
129129
mulIndicator s f ≤ mulIndicator t f :=
130130
fun _ ↦ mulIndicator_le_mulIndicator_apply_of_subset h (hf _)
@@ -186,8 +186,9 @@ lemma iSup_mulIndicator {ι : Type*} [Preorder ι] [IsDirected ι (· ≤ ·)] {
186186
{s : ι → Set α} (h1 : (⊥ : M) = 1) (hf : Monotone f) (hs : Monotone s) :
187187
⨆ i, (s i).mulIndicator (f i) = (⋃ i, s i).mulIndicator (⨆ i, f i) := by
188188
simp only [le_antisymm_iff, iSup_le_iff]
189-
refine ⟨fun i ↦ (mulIndicator_mono (le_iSup _ _)).trans (mulIndicator_le_mulIndicator_of_subset
190-
(subset_iUnion _ _) (fun _ ↦ by simp [← h1])), fun a ↦ ?_⟩
189+
refine ⟨fun i ↦ ?_, fun a ↦ ?_⟩
190+
· grw [← le_iSup f i, ← subset_iUnion s i]
191+
intro; simp [← h1]
191192
by_cases ha : a ∈ ⋃ i, s i
192193
· obtain ⟨i, hi⟩ : ∃ i, a ∈ s i := by simpa using ha
193194
rw [mulIndicator_of_mem ha, iSup_apply, iSup_apply]

Mathlib/Analysis/Normed/Group/Indicator.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ lemma enorm_indicator_eq_indicator_enorm :
3434
theorem enorm_indicator_le_of_subset (h : s ⊆ t) (f : α → ε) (a : α) :
3535
‖indicator s f a‖ₑ ≤ ‖indicator t f a‖ₑ := by
3636
simp only [enorm_indicator_eq_indicator_enorm]
37-
apply indicator_le_indicator_of_subset ‹_› (zero_le _)
37+
grw [h]
3838

3939
theorem indicator_enorm_le_enorm_self : indicator s (fun a => ‖f a‖ₑ) a ≤ ‖f a‖ₑ :=
4040
indicator_le_self' (fun _ _ ↦ zero_le _) a
@@ -59,7 +59,7 @@ theorem nnnorm_indicator_eq_indicator_nnnorm :
5959
theorem norm_indicator_le_of_subset (h : s ⊆ t) (f : α → E) (a : α) :
6060
‖indicator s f a‖ ≤ ‖indicator t f a‖ := by
6161
simp only [norm_indicator_eq_indicator_norm]
62-
exact indicator_le_indicator_of_subset ‹_› (fun _ => norm_nonneg _) _
62+
grw [h]
6363

6464
theorem indicator_norm_le_norm_self : indicator s (fun a => ‖f a‖) a ≤ ‖f a‖ :=
6565
indicator_le_self' (fun _ _ => norm_nonneg _) a

Mathlib/MeasureTheory/Function/SimpleFunc.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ lemma Measurable.ennreal_sigmaFinite_induction [SigmaFinite μ] {motive : (α
14291429
refine Measurable.ennreal_induction (fun c s hs ↦ ?_) add iSup hf
14301430
convert iSup (f := fun n ↦ (s ∩ spanningSets μ n).indicator fun _ ↦ c)
14311431
(fun n ↦ measurable_const.indicator (hs.inter (measurableSet_spanningSets ..)))
1432-
(fun m n hmn a ↦ Set.indicator_le_indicator_of_subset (by gcongr) (by simp) _)
1432+
(fun m n hmn a ↦ by dsimp; grw [hmn])
14331433
(fun n ↦ indicator _ (hs.inter (measurableSet_spanningSets ..))
14341434
(measure_inter_lt_top_of_right_ne_top (measure_spanningSets_lt_top ..).ne)) with a
14351435
simp [← Set.indicator_iUnion_apply (M := ℝ≥0∞) rfl, ← Set.inter_iUnion]

Mathlib/MeasureTheory/Function/UniformIntegrable.lean

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,8 @@ theorem MemLp.eLpNorm_indicator_norm_ge_pos_le (hf : MemLp f p μ) (hmeas : Stro
311311
obtain ⟨M, hM⟩ := hf.eLpNorm_indicator_norm_ge_le hmeas hε
312312
refine
313313
⟨max M 1, lt_of_lt_of_le zero_lt_one (le_max_right _ _), le_trans (eLpNorm_mono fun x => ?_) hM⟩
314-
rw [norm_indicator_eq_indicator_norm, norm_indicator_eq_indicator_norm]
315-
refine Set.indicator_le_indicator_of_subset (fun x hx => ?_) (fun x => norm_nonneg (f x)) x
316-
rw [Set.mem_setOf_eq] at hx -- removing the `rw` breaks the proof!
317-
exact (max_le_iff.1 hx).1
314+
simp only [norm_indicator_eq_indicator_norm]
315+
grw [← le_max_left]
318316

319317
end
320318

@@ -689,8 +687,7 @@ theorem unifIntegrable_of (hp : 1 ≤ p) (hp' : p ≠ ∞) {f : ι → α → β
689687
rwa [Set.mem_setOf, hx] at hfx
690688
refine ⟨max C 1, lt_max_of_lt_right one_pos, fun i => le_trans (eLpNorm_mono fun x => ?_) (hCg i)⟩
691689
rw [norm_indicator_eq_indicator_norm, norm_indicator_eq_indicator_norm]
692-
exact Set.indicator_le_indicator_of_subset
693-
(fun x hx => Set.mem_setOf_eq ▸ le_trans (le_max_left _ _) hx) (fun _ => norm_nonneg _) _
690+
grw [← le_max_left]
694691

695692
end UnifIntegrable
696693

Mathlib/MeasureTheory/Integral/Bochner/VitaliCaratheodory.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ theorem SimpleFunc.exists_le_lowerSemicontinuous_lintegral_ge (f : α →ₛ ℝ
129129
refine ⟨Set.indicator u fun _ => c,
130130
fun x => ?_, u_open.lowerSemicontinuous_indicator (zero_le _), ?_⟩
131131
· simp only [SimpleFunc.coe_const, SimpleFunc.const_zero, SimpleFunc.coe_zero,
132-
Set.piecewise_eq_indicator, SimpleFunc.coe_piecewise]
133-
exact Set.indicator_le_indicator_of_subset su (fun x => zero_le _) _
132+
Set.piecewise_eq_indicator, SimpleFunc.coe_piecewise, ← Function.const_def]
133+
grw [su]
134134
· suffices (c : ℝ≥0∞) * μ u ≤ c * μ s + ε by
135135
classical
136136
simpa only [ENNReal.coe_indicator, u_open.measurableSet, lintegral_indicator,
@@ -340,8 +340,8 @@ theorem SimpleFunc.exists_upperSemicontinuous_le_lintegral_le (f : α →ₛ ℝ
340340
⟨Set.indicator F fun _ => c, fun x => ?_, F_closed.upperSemicontinuous_indicator (zero_le _),
341341
?_⟩
342342
· simp only [SimpleFunc.coe_const, SimpleFunc.const_zero, SimpleFunc.coe_zero,
343-
Set.piecewise_eq_indicator, SimpleFunc.coe_piecewise]
344-
exact Set.indicator_le_indicator_of_subset Fs (fun x => zero_le _) _
343+
Set.piecewise_eq_indicator, SimpleFunc.coe_piecewise, ← Function.const_def]
344+
grw [Fs]
345345
· suffices (c : ℝ≥0∞) * μ s ≤ c * μ F + ε by
346346
classical
347347
simpa only [hs, F_closed.measurableSet, SimpleFunc.coe_const, Function.const_apply,

Mathlib/MeasureTheory/Integral/DominatedConvergence.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ theorem _root_.Antitone.tendsto_setIntegral (hsm : ∀ i, MeasurableSet (s i)) (
197197
exact hfi.norm
198198
· simp_rw [norm_indicator_eq_indicator_norm]
199199
refine fun n => Eventually.of_forall fun x => ?_
200-
exact indicator_le_indicator_of_subset (h_anti (zero_le n)) (fun a => norm_nonneg _) _
200+
grw [(h_anti (zero_le n)).subset]
201201
· filter_upwards [] with a using le_trans (h_anti.tendsto_indicator _ _ _) (pure_le_nhds _)
202202

203203
end TendstoMono

Mathlib/MeasureTheory/Integral/Indicator.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ lemma tendsto_measure_of_ae_tendsto_indicator {μ : Measure α} (A_mble : Measur
5353
(Eventually.of_forall ?_) ?_ ?_ ?_
5454
· exact fun i ↦ Measurable.indicator measurable_const (As_mble i)
5555
· filter_upwards [As_le_B] with i hi
56-
exact Eventually.of_forall (fun x ↦ indicator_le_indicator_of_subset hi (by simp) x)
56+
exact Eventually.of_forall fun x ↦ by grw [hi]
5757
· rwa [← lintegral_indicator_one B_mble] at B_finmeas
5858
· simpa only [Pi.one_def, tendsto_indicator_const_apply_iff_eventually] using h_lim
5959

Mathlib/MeasureTheory/Integral/IntegralEqImproper.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ private theorem lintegral_tendsto_of_monotone_of_nat {φ : ℕ → Set α} (hφ
355355
Tendsto (fun i => ∫⁻ x in φ i, f x ∂μ) atTop (𝓝 <| ∫⁻ x, f x ∂μ) :=
356356
let F n := (φ n).indicator f
357357
have key₁ : ∀ n, AEMeasurable (F n) μ := fun n => hfm.indicator (hφ.measurableSet n)
358-
have key₂ : ∀ᵐ x : α ∂μ, Monotone fun n => F n x := ae_of_all _ fun x _i _j hij =>
359-
indicator_le_indicator_of_subset (hmono hij) (fun x => zero_le <| f x) x
358+
have key₂ : ∀ᵐ x : α ∂μ, Monotone fun n => F n x := ae_of_all _ fun x _i _j hij => by
359+
dsimp [F]; grw [(hmono hij).subset]
360360
have key₃ : ∀ᵐ x : α ∂μ, Tendsto (fun n => F n x) atTop (𝓝 (f x)) := hφ.ae_tendsto_indicator f
361361
(lintegral_tendsto_of_tendsto_of_monotone key₁ key₂ key₃).congr fun n =>
362362
lintegral_indicator (hφ.measurableSet n) _

Mathlib/MeasureTheory/OuterMeasure/Operations.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ instance instLawfulFunctor : LawfulFunctor OuterMeasure := by constructor <;> in
244244
def dirac (a : α) : OuterMeasure α where
245245
measureOf s := indicator s (fun _ => 1) a
246246
empty := by simp
247-
mono {_ _} h := indicator_le_indicator_of_subset h (fun _ => zero_le _) a
247+
mono {_ _} h := by grw [h]
248248
iUnion_nat s _ := calc
249249
indicator (⋃ n, s n) 1 a = ⨆ n, indicator (s n) 1 a :=
250250
indicator_iUnion_apply (M := ℝ≥0∞) rfl _ _ _

0 commit comments

Comments
 (0)