Documentation

Mathlib.Data.Finset.Piecewise

Functions defined piecewise on a finset #

This file defines Finset.piecewise: Given two functions f, g, s.piecewise f g is a function which is equal to f on s and g on the complement.

TODO #

Should we deduplicate this from Set.piecewise?

def Finset.piecewise {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) (f g : (i : ι) → Ļ€ i) [(j : ι) → Decidable (j ∈ s)] (i : ι) :
Ļ€ i

s.piecewise f g is the function equal to f on the finset s, and to g on its complement.

Instances For
    theorem Finset.piecewise_insert_self {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) (f g : (i : ι) → Ļ€ i) [DecidableEq ι] {j : ι} [(i : ι) → Decidable (i ∈ insert j s)] :
    (insert j s).piecewise f g j = f j
    @[simp]
    theorem Finset.piecewise_empty {ι : Type u_1} {Ļ€ : ι → Sort u_2} (f g : (i : ι) → Ļ€ i) [(i : ι) → Decidable (i ∈ āˆ…)] :
    āˆ….piecewise f g = g
    theorem Finset.piecewise_coe {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) (f g : (i : ι) → Ļ€ i) [(j : ι) → Decidable (j ∈ s)] :
    (↑s).piecewise f g = s.piecewise f g
    @[simp]
    theorem Finset.piecewise_eq_of_mem {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) (f g : (i : ι) → Ļ€ i) [(j : ι) → Decidable (j ∈ s)] {i : ι} (hi : i ∈ s) :
    s.piecewise f g i = f i
    @[simp]
    theorem Finset.piecewise_eq_of_notMem {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) (f g : (i : ι) → Ļ€ i) [(j : ι) → Decidable (j ∈ s)] {i : ι} (hi : i āˆ‰ s) :
    s.piecewise f g i = g i
    theorem Finset.piecewise_congr {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) [(j : ι) → Decidable (j ∈ s)] {f f' g g' : (i : ι) → Ļ€ i} (hf : āˆ€ i ∈ s, f i = f' i) (hg : āˆ€ i āˆ‰ s, g i = g' i) :
    s.piecewise f g = s.piecewise f' g'
    @[simp]
    theorem Finset.piecewise_insert_of_ne {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) (f g : (i : ι) → Ļ€ i) [(j : ι) → Decidable (j ∈ s)] [DecidableEq ι] {i j : ι} [(i : ι) → Decidable (i ∈ insert j s)] (h : i ≠ j) :
    (insert j s).piecewise f g i = s.piecewise f g i
    theorem Finset.piecewise_insert {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) (f g : (i : ι) → Ļ€ i) [(j : ι) → Decidable (j ∈ s)] [DecidableEq ι] (j : ι) [(i : ι) → Decidable (i ∈ insert j s)] :
    (insert j s).piecewise f g = Function.update (s.piecewise f g) j (f j)
    theorem Finset.piecewise_cases {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) (f g : (i : ι) → Ļ€ i) [(j : ι) → Decidable (j ∈ s)] {i : ι} (p : Ļ€ i → Prop) (hf : p (f i)) (hg : p (g i)) :
    p (s.piecewise f g i)
    theorem Finset.piecewise_singleton {ι : Type u_1} {Ļ€ : ι → Sort u_2} (f g : (i : ι) → Ļ€ i) [DecidableEq ι] (i : ι) :
    {i}.piecewise f g = Function.update g i (f i)
    theorem Finset.piecewise_piecewise_of_subset_left {ι : Type u_1} {Ļ€ : ι → Sort u_2} {s t : Finset ι} [(i : ι) → Decidable (i ∈ s)] [(i : ι) → Decidable (i ∈ t)] (h : s āŠ† t) (f₁ fā‚‚ g : (a : ι) → Ļ€ a) :
    s.piecewise (t.piecewise f₁ fā‚‚) g = s.piecewise f₁ g
    @[simp]
    theorem Finset.piecewise_idem_left {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) [(j : ι) → Decidable (j ∈ s)] (f₁ fā‚‚ g : (a : ι) → Ļ€ a) :
    s.piecewise (s.piecewise f₁ fā‚‚) g = s.piecewise f₁ g
    theorem Finset.piecewise_piecewise_of_subset_right {ι : Type u_1} {Ļ€ : ι → Sort u_2} {s t : Finset ι} [(i : ι) → Decidable (i ∈ s)] [(i : ι) → Decidable (i ∈ t)] (h : t āŠ† s) (f g₁ gā‚‚ : (a : ι) → Ļ€ a) :
    s.piecewise f (t.piecewise g₁ gā‚‚) = s.piecewise f gā‚‚
    @[simp]
    theorem Finset.piecewise_idem_right {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) [(j : ι) → Decidable (j ∈ s)] (f g₁ gā‚‚ : (a : ι) → Ļ€ a) :
    s.piecewise f (s.piecewise g₁ gā‚‚) = s.piecewise f gā‚‚
    theorem Finset.update_eq_piecewise {ι : Type u_1} {β : Type u_3} [DecidableEq ι] (f : ι → β) (i : ι) (v : β) :
    Function.update f i v = {i}.piecewise (fun (x : ι) => v) f
    theorem Finset.update_piecewise {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) (f g : (i : ι) → Ļ€ i) [(j : ι) → Decidable (j ∈ s)] [DecidableEq ι] (i : ι) (v : Ļ€ i) :
    theorem Finset.update_piecewise_of_mem {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) (f g : (i : ι) → Ļ€ i) [(j : ι) → Decidable (j ∈ s)] [DecidableEq ι] {i : ι} (hi : i ∈ s) (v : Ļ€ i) :
    theorem Finset.update_piecewise_of_notMem {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) (f g : (i : ι) → Ļ€ i) [(j : ι) → Decidable (j ∈ s)] [DecidableEq ι] {i : ι} (hi : i āˆ‰ s) (v : Ļ€ i) :
    theorem Finset.piecewise_same {ι : Type u_1} {Ļ€ : ι → Sort u_2} (s : Finset ι) (f : (i : ι) → Ļ€ i) [(j : ι) → Decidable (j ∈ s)] :
    s.piecewise f f = f
    @[simp]
    theorem Finset.piecewise_univ {ι : Type u_1} {Ļ€ : ι → Sort u_2} [Fintype ι] [(i : ι) → Decidable (i ∈ univ)] (f g : (i : ι) → Ļ€ i) :
    univ.piecewise f g = f
    theorem Finset.piecewise_compl {ι : Type u_1} {Ļ€ : ι → Sort u_2} [Fintype ι] [DecidableEq ι] (s : Finset ι) [(i : ι) → Decidable (i ∈ s)] [(i : ι) → Decidable (i ∈ sᶜ)] (f g : (i : ι) → Ļ€ i) :
    @[simp]
    theorem Finset.piecewise_erase_univ {ι : Type u_1} {Ļ€ : ι → Sort u_2} [Fintype ι] [DecidableEq ι] (i : ι) (f g : (i : ι) → Ļ€ i) :
    (univ.erase i).piecewise f g = Function.update f i (g i)
    theorem Finset.piecewise_mem_set_pi {ι : Type u_1} (s : Finset ι) [(j : ι) → Decidable (j ∈ s)] {Ļ€ : ι → Type u_3} {t : Set ι} {t' : (i : ι) → Set (Ļ€ i)} {f g : (i : ι) → Ļ€ i} (hf : f ∈ t.pi t') (hg : g ∈ t.pi t') :
    s.piecewise f g ∈ t.pi t'
    theorem Finset.piecewise_le_of_le_of_le {ι : Type u_1} (s : Finset ι) [(j : ι) → Decidable (j ∈ s)] {Ļ€ : ι → Type u_3} {f g h : (i : ι) → Ļ€ i} [(i : ι) → Preorder (Ļ€ i)] (hf : f ≤ h) (hg : g ≤ h) :
    theorem Finset.le_piecewise_of_le_of_le {ι : Type u_1} (s : Finset ι) [(j : ι) → Decidable (j ∈ s)] {Ļ€ : ι → Type u_3} {f g h : (i : ι) → Ļ€ i} [(i : ι) → Preorder (Ļ€ i)] (hf : h ≤ f) (hg : h ≤ g) :
    theorem Finset.piecewise_le_piecewise' {ι : Type u_1} (s : Finset ι) [(j : ι) → Decidable (j ∈ s)] {Ļ€ : ι → Type u_3} {f g f' g' : (i : ι) → Ļ€ i} [(i : ι) → Preorder (Ļ€ i)] (hf : āˆ€ x ∈ s, f x ≤ f' x) (hg : āˆ€ x āˆ‰ s, g x ≤ g' x) :
    s.piecewise f g ≤ s.piecewise f' g'
    theorem Finset.piecewise_le_piecewise {ι : Type u_1} (s : Finset ι) [(j : ι) → Decidable (j ∈ s)] {Ļ€ : ι → Type u_3} {f g f' g' : (i : ι) → Ļ€ i} [(i : ι) → Preorder (Ļ€ i)] (hf : f ≤ f') (hg : g ≤ g') :
    s.piecewise f g ≤ s.piecewise f' g'
    theorem Finset.piecewise_mem_Icc_of_mem_of_mem {ι : Type u_1} (s : Finset ι) [(j : ι) → Decidable (j ∈ s)] {Ļ€ : ι → Type u_3} {f g f' g' : (i : ι) → Ļ€ i} [(i : ι) → Preorder (Ļ€ i)] (hf : f ∈ Set.Icc f' g') (hg : g ∈ Set.Icc f' g') :
    s.piecewise f g ∈ Set.Icc f' g'
    theorem Finset.piecewise_mem_Icc {ι : Type u_1} (s : Finset ι) [(j : ι) → Decidable (j ∈ s)] {Ļ€ : ι → Type u_3} {f g : (i : ι) → Ļ€ i} [(i : ι) → Preorder (Ļ€ i)] (h : f ≤ g) :
    s.piecewise f g ∈ Set.Icc f g
    theorem Finset.piecewise_mem_Icc' {ι : Type u_1} (s : Finset ι) [(j : ι) → Decidable (j ∈ s)] {Ļ€ : ι → Type u_3} {f g : (i : ι) → Ļ€ i} [(i : ι) → Preorder (Ļ€ i)] (h : g ≤ f) :
    s.piecewise f g ∈ Set.Icc g f