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
?
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_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.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)
:
Function.update (s.piecewise f g) i v = s.piecewise (Function.update f i v) (Function.update g i v)
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)
:
Function.update (s.piecewise f g) i v = s.piecewise (Function.update f i v) g
theorem
Finset.update_piecewise_of_not_mem
{ι : Type u_1}
{π : ι → Sort u_2}
(s : Finset ι)
(f g : (i : ι) → π i)
[(j : ι) → Decidable (j ∈ s)]
[DecidableEq ι]
{i : ι}
(hi : i ∉ s)
(v : π i)
:
Function.update (s.piecewise f g) i v = s.piecewise f (Function.update g i v)
@[simp]
theorem
Finset.piecewise_erase_univ
{ι : Type u_1}
{π : ι → Sort u_2}
[Fintype ι]
[DecidableEq ι]
(i : ι)
(f g : (i : ι) → π i)
:
(Finset.univ.erase i).piecewise f g = Function.update f i (g i)