Dependent functions with finite support #
For a non-dependent version see data/finsupp.lean
.
Notation #
This file introduces the notation Π₀ a, β a
as notation for DFinsupp β
, mirroring the α →₀ β
notation used for Finsupp
. This works for nested binders too, with Π₀ a b, γ a b
as notation
for DFinsupp (fun a ↦ DFinsupp (γ a))
.
Implementation notes #
The support is internally represented (in the primed DFinsupp.support'
) as a Multiset
that
represents a superset of the true support of the function, quotiented by the always-true relation so
that this does not impact equality. This approach has computational benefits over storing a
Finset
; it allows us to add together two finitely-supported functions without
having to evaluate the resulting function to recompute its support (which would required
decidability of b = 0
for b : β i
).
The true support of the function can still be recovered with DFinsupp.support
; but these
decidability obligations are now postponed to when the support is actually needed. As a consequence,
there are two ways to sum a DFinsupp
: with DFinsupp.sum
which works over an arbitrary function
but requires recomputation of the support and therefore a Decidable
argument; and with
DFinsupp.sumAddHom
which requires an additive morphism, using its properties to show that
summing over a superset of the support is sufficient.
Finsupp
takes an altogether different approach here; it uses Classical.Decidable
and declares
the Add
instance as noncomputable. This design difference is independent of the fact that
DFinsupp
is dependently-typed and Finsupp
is not; in future, we may want to align these two
definitions, or introduce two more definitions for the other combinations of decisions.
- mk' :: (
- toFun : (i : ι) → β i
The underlying function of a dependent function with finite support (aka
DFinsupp
). - support' : Trunc { s_1 // ∀ (i : ι), i ∈ s_1 ∨ DFinsupp.toFun s i = 0 }
The support of a dependent function with finite support (aka
DFinsupp
). - )
A dependent function Π i, β i
with finite support, with notation Π₀ i, β i
.
Note that DFinsupp.support
is the preferred API for accessing the support of the function,
DFinsupp.support'
is an implementation detail that aids computability; see the implementation
notes in this file for more information.
Instances For
Π₀ i, β i
denotes the type of dependent functions with finite support DFinsupp β
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
A dependent function Π i, β i
with finite support, with notation Π₀ i, β i
.
Note that DFinsupp.support
is the preferred API for accessing the support of the function,
DFinsupp.support'
is an implementation detail that aids computability; see the implementation
notes in this file for more information.
Equations
- «term_→ₚ_» = Lean.ParserDescr.trailingNode `term_→ₚ_ 25 25 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " →ₚ ") (Lean.ParserDescr.cat `term 26))
Instances For
Helper instance for when there are too many metavariables to apply FunLike.coeFunForall
directly.
Equations
- DFinsupp.instCoeFunDFinsuppForAll = inferInstance
The composition of f : β₁ → β₂
and g : Π₀ i, β₁ i
is
mapRange f hf g : Π₀ i, β₂ i
, well defined when f 0 = 0
.
This preserves the structure on f
, and exists in various bundled forms for when f
is itself
bundled:
DFinsupp.mapRange.addMonoidHom
DFinsupp.mapRange.addEquiv
dfinsupp.mapRange.linearMap
dfinsupp.mapRange.linearEquiv
Equations
- One or more equations did not get rendered due to their size.
Instances For
Let f i
be a binary operation β₁ i → β₂ i → β i
such that f i 0 0 = 0
.
Then zipWith f hf
is a binary operation Π₀ i, β₁ i → Π₀ i, β₂ i → Π₀ i, β i
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
x.piecewise y s
is the finitely supported function equal to x
on the set s
,
and to y
on its complement.
Equations
- DFinsupp.piecewise x y s = DFinsupp.zipWith (fun i x y => if i ∈ s then x else y) (_ : ∀ (x : ι), (if x ∈ s then 0 else 0) = 0) x y
Instances For
Equations
- DFinsupp.instAddDFinsuppToZero = { add := DFinsupp.zipWith (fun x x_1 x_2 => x_1 + x_2) (_ : ∀ (x : ι), 0 + 0 = 0) }
Equations
- DFinsupp.addZeroClass = Function.Injective.addZeroClass (fun f => ↑f) (_ : Function.Injective fun f => ↑f) (_ : ↑0 = 0) (_ : ∀ (g₁ g₂ : Π₀ (i : ι), β i), ↑(g₁ + g₂) = ↑g₁ + ↑g₂)
Note the general SMul
instance doesn't apply as ℕ
is not distributive
unless β i
's addition is commutative.
Equations
- DFinsupp.hasNatScalar = { smul := fun c v => DFinsupp.mapRange (fun x => (fun x_1 x_2 => x_1 • x_2) c) (_ : ∀ (x : ι), c • 0 = 0) v }
Coercion from a DFinsupp
to a pi type is an AddMonoidHom
.
Equations
Instances For
Evaluation at a point is an AddMonoidHom
. This is the finitely-supported version of
Pi.evalAddMonoidHom
.
Equations
- DFinsupp.evalAddMonoidHom i = AddMonoidHom.comp (Pi.evalAddMonoidHom β i) DFinsupp.coeFnAddMonoidHom
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- DFinsupp.instNegDFinsuppToZeroToNegZeroClassToSubNegZeroMonoidToSubtractionMonoid = { neg := fun f => DFinsupp.mapRange (fun x => Neg.neg) (_ : ∀ (x : ι), -0 = 0) f }
Equations
- DFinsupp.instSubDFinsuppToZeroToNegZeroClassToSubNegZeroMonoidToSubtractionMonoid = { sub := DFinsupp.zipWith (fun x => Sub.sub) (_ : ∀ (x : ι), 0 - 0 = 0) }
Note the general SMul
instance doesn't apply as ℤ
is not distributive
unless β i
's addition is commutative.
Equations
- DFinsupp.hasIntScalar = { smul := fun c v => DFinsupp.mapRange (fun x => (fun x_1 x_2 => x_1 • x_2) c) (_ : ∀ (x : ι), c • 0 = 0) v }
Equations
- One or more equations did not get rendered due to their size.
Dependent functions with finite support inherit a semiring action from an action on each coordinate.
Equations
- DFinsupp.instSMulDFinsuppToZero = { smul := fun c v => DFinsupp.mapRange (fun x => (fun x_1 x_2 => x_1 • x_2) c) (_ : ∀ (x : ι), c • 0 = 0) v }
Dependent functions with finite support inherit a DistribMulAction
structure from such a
structure on each coordinate.
Equations
- DFinsupp.distribMulAction = Function.Injective.distribMulAction DFinsupp.coeFnAddMonoidHom (_ : Function.Injective fun f => ↑f) (_ : ∀ (b : γ) (v : Π₀ (i : ι), β i), ↑(b • v) = b • ↑v)
Dependent functions with finite support inherit a module structure from such a structure on each coordinate.
Equations
- One or more equations did not get rendered due to their size.
Filter p f
is the function which is f i
if p i
is true and 0 otherwise.
Equations
- One or more equations did not get rendered due to their size.
Instances For
DFinsupp.filter
as an AddMonoidHom
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
DFinsupp.filter
as a LinearMap
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
subtypeDomain p f
is the restriction of the finitely supported function
f
to the subtype p
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
subtypeDomain
but as an AddMonoidHom
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
DFinsupp.subtypeDomain
as a LinearMap
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Create an element of Π₀ i, β i
from a finset s
and a function x
defined on this Finset
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- DFinsupp.unique = Function.Injective.unique (_ : Function.Injective fun f => ↑f)
Equations
- DFinsupp.uniqueOfIsEmpty = Function.Injective.unique (_ : Function.Injective fun f => ↑f)
Given Fintype ι
, equivFunOnFintype
is the Equiv
between Π₀ i, β i
and Π i, β i
.
(All dependent functions on a finite type are finitely supported.)
Equations
- One or more equations did not get rendered due to their size.
Instances For
The function single i b : Π₀ i, β i
sends i
to b
and all other points to 0
.
Equations
Instances For
Like Finsupp.single_eq_single_iff
, but with a HEq
due to dependent types
DFinsupp.single a b
is injective in a
. For the statement that it is injective in b
, see
DFinsupp.single_injective
Equality of sigma types is sufficient (but not necessary) to show equality of DFinsupp
s.
Redefine f i
to be 0
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Replace the value of a Π₀ i, β i
at a given point i : ι
by a given value b : β i
.
If b = 0
, this amounts to removing i
from the support.
Otherwise, i
is added to it.
This is the (dependent) finitely-supported version of Function.update
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
DFinsupp.single
as an AddMonoidHom
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
DFinsupp.erase
as an AddMonoidHom
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
If two additive homomorphisms from Π₀ i, β i
are equal on each single a b
, then
they are equal.
If two additive homomorphisms from Π₀ i, β i
are equal on each single a b
, then
they are equal.
See note [partially-applied ext lemmas].
If s
is a subset of ι
then mk_addGroupHom s
is the canonical additive
group homomorphism from $\prod_{i\in s}\beta_i$ to $\prod_{\mathtt{i : \iota}}\beta_i.$
Equations
- One or more equations did not get rendered due to their size.
Instances For
Set {i | f x ≠ 0}
as a Finset
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equivalence between dependent functions with finite support s : Finset ι
and functions
∀ i, {x : β i // x ≠ 0}
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equivalence between all dependent finitely supported functions f : Π₀ i, β i
and type
of pairs ⟨s : Finset ι, f : ∀ i : s, {x : β i // x ≠ 0}⟩
.
Equations
- DFinsupp.sigmaFinsetFunEquiv = (Equiv.sigmaFiberEquiv DFinsupp.support).symm.trans (Equiv.sigmaCongrRight DFinsupp.subtypeSupportEqEquiv)
Instances For
Equations
- DFinsupp.decidableZero x = decidable_of_iff (DFinsupp.support x = ∅) (_ : DFinsupp.support x = ∅ ↔ 0 = x)
Equations
- One or more equations did not get rendered due to their size.
Reindexing (and possibly removing) terms of a dfinsupp.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A computable version of comap_domain when an explicit left inverse is provided.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Reindexing terms of a dfinsupp.
This is the dfinsupp version of Equiv.piCongrLeft'
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- DFinsupp.hasAdd₂ = inferInstance
Equations
- DFinsupp.addZeroClass₂ = inferInstance
Equations
- DFinsupp.distribMulAction₂ = DFinsupp.distribMulAction
The natural map between Π₀ (i : Σ i, α i), δ i.1 i.2
and Π₀ i (j : α i), δ i j
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The natural map between Π₀ i (j : α i), δ i j
and Π₀ (i : Σ i, α i), δ i.1 i.2
, inverse of
curry
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The natural bijection between Π₀ (i : Σ i, α i), δ i.1 i.2
and Π₀ i (j : α i), δ i j
.
This is the dfinsupp version of Equiv.piCurry
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Adds a term to a dfinsupp, making a dfinsupp indexed by an Option
.
This is the dfinsupp version of Option.rec
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Bijection obtained by separating the term of index none
of a dfinsupp over Option ι
.
This is the dfinsupp version of Equiv.piOptionEquivProd
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
sum f g
is the sum of g i (f i)
over the support of f
.
Equations
- DFinsupp.sum f g = Finset.sum (DFinsupp.support f) fun i => g i (↑f i)
Instances For
DFinsupp.prod f g
is the product of g i (f i)
over the support of f
.
Equations
- DFinsupp.prod f g = Finset.prod (DFinsupp.support f) fun i => g i (↑f i)
Instances For
When summing over an AddMonoidHom
, the decidability assumption is not needed, and the result is
also an AddMonoidHom
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
While we didn't need decidable instances to define it, we do to reduce it to a sum
The supremum of a family of commutative additive submonoids is equal to the range of
DFinsupp.sumAddHom
; that is, every element in the iSup
can be produced from taking a finite
number of non-zero elements of S i
, coercing them to γ
, and summing them.
The bounded supremum of a family of commutative additive submonoids is equal to the range of
DFinsupp.sumAddHom
composed with DFinsupp.filterAddMonoidHom
; that is, every element in the
bounded iSup
can be produced from taking a finite number of non-zero elements from the S i
that
satisfy p i
, coercing them to γ
, and summing them.
A variant of AddSubmonoid.mem_iSup_iff_exists_dfinsupp
with the RHS fully unfolded.
The DFinsupp
version of Finsupp.liftAddHom
,
Equations
- One or more equations did not get rendered due to their size.
Instances For
The DFinsupp
version of Finsupp.liftAddHom_singleAddHom
,
The DFinsupp
version of Finsupp.liftAddHom_apply_single
,
The DFinsupp
version of Finsupp.liftAddHom_comp_single
,
The DFinsupp
version of Finsupp.comp_liftAddHom
,
Equations
- DFinsupp.sum_subtypeDomain_index.match_1 motive x h_1 = Subtype.casesOn x fun val property => h_1 val property
Instances For
Bundled versions of DFinsupp.mapRange
#
The names should match the equivalent bundled Finsupp.mapRange
definitions.
DFinsupp.mapRange
as an AddMonoidHom
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
DFinsupp.mapRange.addMonoidHom
as an AddEquiv
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Product and sum lemmas for bundled morphisms. #
In this section, we provide analogues of AddMonoidHom.map_sum
, AddMonoidHom.coe_finset_sum
,
and AddMonoidHom.finset_sum_apply
for DFinsupp.sum
and DFinsupp.sumAddHom
instead of
Finset.sum
.
We provide these for AddMonoidHom
, MonoidHom
, RingHom
, AddEquiv
, and MulEquiv
.
Lemmas for LinearMap
and LinearEquiv
are in another file.
The above lemmas, repeated for DFinsupp.sumAddHom
.
Equations
- DFinsupp.fintype = Fintype.ofEquiv ((i : ι) → π i) DFinsupp.equivFunOnFintype.symm
See DFinsupp.infinite_of_right
for this in instance form, with the drawback that
it needs all π i
to be infinite.
See DFinsupp.infinite_of_exists_right
for the case that only one π ι
is infinite.