Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 4a63f3f

Browse files
committed
feat(data/indicator_function): add indicator_range_comp (#3343)
Add * `comp_eq_of_eq_on_range`; * `piecewise_eq_on`; * `piecewise_eq_on_compl`; * `piecewise_compl`; * `piecewise_range_comp`; * `indicator_range_comp`.
1 parent d6ecb44 commit 4a63f3f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/data/indicator_function.lean

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ lemma eq_on_indicator : eq_on (indicator s f) f s := λ x hx, indicator_of_mem h
5151
lemma support_indicator : function.support (s.indicator f) ⊆ s :=
5252
λ x hx, hx.imp_symm (λ h, indicator_of_not_mem h f)
5353

54+
@[simp] lemma indicator_range_comp {ι : Sort*} (f : ι → α) (g : α → β) :
55+
indicator (range f) g ∘ f = g ∘ f :=
56+
piecewise_range_comp _ _ _
57+
5458
lemma indicator_congr (h : ∀ a ∈ s, f a = g a) : indicator s f = indicator s g :=
5559
funext $ λx, by { simp only [indicator], split_ifs, { exact h _ h_1 }, refl }
5660

@@ -203,7 +207,7 @@ by { rw indicator_apply, split_ifs with as, { exact h as }, refl }
203207
lemma indicator_nonpos (h : ∀ a ∈ s, f a ≤ 0) : ∀ a, indicator s f a ≤ 0 :=
204208
λ a, indicator_nonpos' (h a)
205209

206-
lemma indicator_le_indicator (h : f a ≤ g a) : indicator s f a ≤ indicator s g a :=
210+
@[mono] lemma indicator_le_indicator (h : f a ≤ g a) : indicator s f a ≤ indicator s g a :=
207211
by { simp only [indicator], split_ifs with ha, { exact h }, refl }
208212

209213
lemma indicator_le_indicator_of_subset (h : s ⊆ t) (hf : ∀a, 0 ≤ f a) (a : α) :

src/data/set/function.lean

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ image_congr heq
8888
lemma eq_on.mono (hs : s₁ ⊆ s₂) (hf : eq_on f₁ f₂ s₂) : eq_on f₁ f₂ s₁ :=
8989
λ x hx, hf (hs hx)
9090

91+
lemma comp_eq_of_eq_on_range {ι : Sort*} {f : ι → α} {g₁ g₂ : α → β} (h : eq_on g₁ g₂ (range f)) :
92+
g₁ ∘ f = g₂ ∘ f :=
93+
funext $ λ x, h $ mem_range_self _
94+
9195
/-! ### maps to -/
9296

9397
/-- `maps_to f a b` means that the image of `a` is contained in `b`. -/
@@ -443,11 +447,25 @@ by simp [piecewise, hi]
443447
lemma piecewise_eq_of_not_mem {i : α} (hi : i ∉ s) : s.piecewise f g i = g i :=
444448
by simp [piecewise, hi]
445449

450+
lemma piecewise_eq_on (f g : α → β) : eq_on (s.piecewise f g) f s :=
451+
λ _, piecewise_eq_of_mem _ _ _
452+
453+
lemma piecewise_eq_on_compl (f g : α → β) : eq_on (s.piecewise f g) g sᶜ :=
454+
λ _, piecewise_eq_of_not_mem _ _ _
455+
446456
@[simp, priority 990]
447457
lemma piecewise_insert_of_ne {i j : α} (h : i ≠ j) [∀i, decidable (i ∈ insert j s)] :
448458
(insert j s).piecewise f g i = s.piecewise f g i :=
449459
by simp [piecewise, h]
450460

461+
@[simp] lemma piecewise_compl [∀ i, decidable (i ∈ sᶜ)] : sᶜ.piecewise f g = s.piecewise g f :=
462+
funext $ λ x, if hx : x ∈ s then by simp [hx] else by simp [hx]
463+
464+
@[simp] lemma piecewise_range_comp {ι : Sort*} (f : ι → α) [Π j, decidable (j ∈ range f)]
465+
(g₁ g₂ : α → β) :
466+
(range f).piecewise g₁ g₂ ∘ f = g₁ ∘ f :=
467+
comp_eq_of_eq_on_range $ piecewise_eq_on _ _ _
468+
451469
end set
452470

453471
namespace function

0 commit comments

Comments
 (0)