Connections between Finsupp
and AList
#
Main definitions #
Finsupp.toAList
AList.lookupFinsupp
: converts an association list into a finitely supported function viaAList.lookup
, sending absent keys to zero.
@[simp]
theorem
Finsupp.toAList_entries
{α : Type u_1}
{M : Type u_2}
[Zero M]
(f : α →₀ M)
:
(Finsupp.toAList f).entries = List.map Prod.toSigma (Finset.toList (Finsupp.graph f))
noncomputable def
Finsupp.toAList
{α : Type u_1}
{M : Type u_2}
[Zero M]
(f : α →₀ M)
:
AList fun (_x : α) => M
Produce an association list for the finsupp over its support using choice.
Equations
- Finsupp.toAList f = { entries := List.map Prod.toSigma (Finset.toList (Finsupp.graph f)), nodupKeys := (_ : List.NodupKeys (List.map Prod.toSigma (Finset.toList (Finsupp.graph f)))) }
Instances For
@[simp]
theorem
Finsupp.toAList_keys_toFinset
{α : Type u_1}
{M : Type u_2}
[Zero M]
[DecidableEq α]
(f : α →₀ M)
:
List.toFinset (AList.keys (Finsupp.toAList f)) = f.support
@[simp]
theorem
Finsupp.mem_toAlist
{α : Type u_1}
{M : Type u_2}
[Zero M]
{f : α →₀ M}
{x : α}
:
x ∈ Finsupp.toAList f ↔ f x ≠ 0
noncomputable def
AList.lookupFinsupp
{α : Type u_1}
{M : Type u_2}
[Zero M]
(l : AList fun (_x : α) => M)
:
α →₀ M
Converts an association list into a finitely supported function via AList.lookup
, sending
absent keys to zero.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]
theorem
AList.lookupFinsupp_apply
{α : Type u_1}
{M : Type u_2}
[Zero M]
[DecidableEq α]
(l : AList fun (_x : α) => M)
(a : α)
:
(AList.lookupFinsupp l) a = Option.getD (AList.lookup a l) 0
@[simp]
theorem
AList.lookupFinsupp_support
{α : Type u_1}
{M : Type u_2}
[Zero M]
[DecidableEq α]
[DecidableEq M]
(l : AList fun (_x : α) => M)
:
(AList.lookupFinsupp l).support = List.toFinset (List.keys (List.filter (fun (x : (_ : α) × M) => decide (x.snd ≠ 0)) l.entries))
theorem
AList.lookupFinsupp_eq_iff_of_ne_zero
{α : Type u_1}
{M : Type u_2}
[Zero M]
[DecidableEq α]
{l : AList fun (_x : α) => M}
{a : α}
{x : M}
(hx : x ≠ 0)
:
(AList.lookupFinsupp l) a = x ↔ x ∈ AList.lookup a l
theorem
AList.lookupFinsupp_eq_zero_iff
{α : Type u_1}
{M : Type u_2}
[Zero M]
[DecidableEq α]
{l : AList fun (_x : α) => M}
{a : α}
:
(AList.lookupFinsupp l) a = 0 ↔ a ∉ l ∨ 0 ∈ AList.lookup a l
@[simp]
@[simp]
theorem
AList.insert_lookupFinsupp
{α : Type u_1}
{M : Type u_2}
[Zero M]
[DecidableEq α]
(l : AList fun (_x : α) => M)
(a : α)
(m : M)
:
AList.lookupFinsupp (AList.insert a m l) = Finsupp.update (AList.lookupFinsupp l) a m
@[simp]
theorem
AList.singleton_lookupFinsupp
{α : Type u_1}
{M : Type u_2}
[Zero M]
(a : α)
(m : M)
:
AList.lookupFinsupp (AList.singleton a m) = Finsupp.single a m
@[simp]
theorem
AList.lookupFinsupp_surjective
{α : Type u_1}
{M : Type u_2}
[Zero M]
:
Function.Surjective AList.lookupFinsupp