Finite functions #
Given types α and β, and assuming that β has a Zero element,
a FinFun α β is a function from α to β where only a finite number of elements
in α are mapped to non-zero elements.
A FinFun is a function fn with a finite support.
This is similar to Finsupp in Mathlib, but definitions are computable.
Equations
- Cslib.FinFun.«term_→₀_» = Lean.ParserDescr.trailingNode `Cslib.FinFun.«term_→₀_» 25 26 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " →₀ ") (Lean.ParserDescr.cat `term 25))
Instances For
def
Cslib.FinFun.fromFun
{α : Type u_1}
{β : Type u_2}
[Zero β]
[DecidableEq α]
[(y : β) → Decidable (y = 0)]
(fn : α → β)
(support : Finset α)
:
FinFun α β
Constructs a FinFun by restricting a function to a given support, filtering out all elements
not mapped to 0 in the support.
Equations
- Cslib.FinFun.fromFun fn support = { fn := fun (a : α) => if a ∈ support then fn a else 0, support := Finset.filter (fun (x : α) => fn x ≠ 0) support, mem_support_fn := ⋯ }
Instances For
Constructs a FinFun by restricting a function to a given support, filtering out all elements
not mapped to 0 in the support.
Equations
- Cslib.FinFun.«term_↾₀_» = Lean.ParserDescr.trailingNode `Cslib.FinFun.«term_↾₀_» 1022 25 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "↾₀") (Lean.ParserDescr.cat `term 51))
Instances For
Equations
- Cslib.FinFun.instFunLike = { coe := fun (f : Cslib.FinFun α β) => f.fn, coe_injective' := ⋯ }
theorem
Cslib.FinFun.fromFun_support
{β : Type u_1}
{α : Type u_2}
[Zero β]
[DecidableEq α]
[(y : β) → Decidable (y = 0)]
(f : α → β)
(support : Finset α)
:
theorem
Cslib.FinFun.fromFun_inter
{β : Type u_1}
{α : Type u_2}
[Zero β]
[DecidableEq α]
[(y : β) → Decidable (y = 0)]
{f : α → β}
{support1 support2 : Finset α}
:
Restricting a function twice to two supports is equal to restricting to their intersection.