Operations on Finsupps with an Option domain #
Similar to how Finsupp.cons and Finsupp.tail construct
an object of type Fin (n + 1) →₀ M from a map Fin n →₀ M and vice versa,
we define Finsupp.optionElim and Finsupp.some
to construct Option α →₀ M from a map α →₀ M, and vice versa.
As functions, these behave as Option.elim', and as an application of some hence the names.
We prove a variety of API lemmas, see Data/Finsupp/Fin.lean for comparison.
Main declarations #
Finsupp.some: restrict a finitely supported function onOption αto a finitely supported function onα.Finsupp.optionElim: extend a finitely supported function onαto a finitely supported function onOption α, provided a default value fornone.
Implementation notes #
This file is a noncomputable theory and uses classical logic throughout.
@[simp]
@[simp]
@[simp]
@[simp]
Extend a finitely supported function on α to a finitely supported function on Option α,
provided a default value for none.
Equations
Instances For
theorem
Finsupp.optionElim_apply_some
{α : Type u_1}
{M : Type u_2}
[Zero M]
(y : M)
(f : α →₀ M)
(x : α)
:
@[simp]
@[simp]
theorem
Finsupp.prod_option_index
{α : Type u_1}
{M : Type u_2}
{N : Type u_3}
[AddZeroClass M]
[CommMonoid N]
(f : Option α →₀ M)
(b : Option α → M → N)
(h_zero : ∀ (o : Option α), b o 0 = 1)
(h_add : ∀ (o : Option α) (m₁ m₂ : M), b o (m₁ + m₂) = b o m₁ * b o m₂)
:
theorem
Finsupp.sum_option_index
{α : Type u_1}
{M : Type u_2}
{N : Type u_3}
[AddZeroClass M]
[AddCommMonoid N]
(f : Option α →₀ M)
(b : Option α → M → N)
(h_zero : ∀ (o : Option α), b o 0 = 0)
(h_add : ∀ (o : Option α) (m₁ m₂ : M), b o (m₁ + m₂) = b o m₁ + b o m₂)
: