Documentation

Cslib.Foundations.Data.FinFun

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.

structure Cslib.FinFun (α : Type u_1) (β : Type u_2) [Zero β] :
Type (max u_1 u_2)

A FinFun is a function fn with a finite support.

This is similar to Finsupp in Mathlib, but definitions are computable.

  • fn : αβ

    The underlying function.

  • support : Finset α

    The finite support of the function.

  • mem_support_fn {a : α} : a self.support self.fn a 0

    Proof that support is the support of the underlying function.

Instances For

    A FinFun is a function fn with a finite support.

    This is similar to Finsupp in Mathlib, but definitions are computable.

    Equations
    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
      Instances For
        instance Cslib.FinFun.instFunLike {β : Type u_1} {α : Type u_2} [Zero β] :
        FunLike (FinFun α β) α β
        Equations
        theorem Cslib.FinFun.coe_fn {β : Type u_1} {α : Type u_2} [Zero β] {f : FinFun α β} :
        f = f.fn
        theorem Cslib.FinFun.coe_eq_fn {β : Type u_1} {α : Type u_2} {a : α} [Zero β] {f : FinFun α β} :
        f a = f.fn a
        theorem Cslib.FinFun.ext {β : Type u_1} {α : Type u_2} [Zero β] {f g : FinFun α β} (h : ∀ (a : α), f a = g a) :
        f = g

        Extensional equality for FinFun.

        theorem Cslib.FinFun.mem_support_not_zero {β : Type u_1} {α : Type u_2} {a : α} [Zero β] {f : FinFun α β} :
        a f.support f a 0
        theorem Cslib.FinFun.not_mem_support_zero {β : Type u_1} {α : Type u_2} {a : α} [Zero β] {f : FinFun α β} :
        af.support f a = 0
        theorem Cslib.FinFun.eq_fields_eq {β : Type u_1} {α : Type u_2} [Zero β] {f g : FinFun α β} :
        f = gf.fn = g.fn f.support = g.support

        If two FinFuns are equal, their underlying functions and supports are equal.

        theorem Cslib.FinFun.fn_eq_eq {β : Type u_1} {α : Type u_2} [Zero β] {f g : FinFun α β} (h : f.fn = g.fn) :
        f = g

        If two functions are equal, two FinFuns respectively using them as underlying functions are equal.

        theorem Cslib.FinFun.congrFinFun {β : Type u_1} {α : Type u_2} [Zero β] {f g : FinFun α β} (h : f = g) (a : α) :
        f a = g a
        theorem Cslib.FinFun.fromFun_eq {β : Type u_1} {α : Type u_2} [Zero β] [DecidableEq α] [(y : β) → Decidable (y = 0)] (f : αβ) (support : Finset α) (h : asupport, f a = 0) :
        (Cslib.FinFun.fromFun✝ f support) = f
        theorem Cslib.FinFun.fromFun_fn {β : Type u_1} {α : Type u_2} [Zero β] [DecidableEq α] [(y : β) → Decidable (y = 0)] (f : αβ) (support : Finset α) :
        (Cslib.FinFun.fromFun✝ f support).fn = fun (a : α) => if a support then f a else 0
        theorem Cslib.FinFun.fromFun_support {β : Type u_1} {α : Type u_2} [Zero β] [DecidableEq α] [(y : β) → Decidable (y = 0)] (f : αβ) (support : Finset α) :
        (Cslib.FinFun.fromFun✝ f support).support = Finset.filter (fun (x : α) => f x 0) support
        theorem Cslib.FinFun.fromFun_idem {β : Type u_1} {α : Type u_2} [Zero β] [DecidableEq α] [(y : β) → Decidable (y = 0)] {f : αβ} {support : Finset α} :

        Restricting a function twice to the same support is idempotent.

        theorem Cslib.FinFun.coe_fromFun_id {β : Type u_1} {α : Type u_2} [Zero β] [DecidableEq α] [(y : β) → Decidable (y = 0)] {f : FinFun α β} :

        Restricting a FinFun to its own support is the identity.

        theorem Cslib.FinFun.fromFun_inter {β : Type u_1} {α : Type u_2} [Zero β] [DecidableEq α] [(y : β) → Decidable (y = 0)] {f : αβ} {support1 support2 : Finset α} :
        Cslib.FinFun.fromFun✝ (⇑(Cslib.FinFun.fromFun✝¹ f support1)) support2 = Cslib.FinFun.fromFun✝² f (support1 support2)

        Restricting a function twice to two supports is equal to restricting to their intersection.

        theorem Cslib.FinFun.fromFun_comm {β : Type u_1} {α : Type u_2} [Zero β] [DecidableEq α] [(y : β) → Decidable (y = 0)] {f : αβ} {support1 support2 : Finset α} :

        Restricting a function is commutative.