The areas / V33. Data structures and computation
Mathlib.Data.List.ToFinsupp
15 declarations. Mathlib docs · Source
Lists as finsupp
Main definitions
List.toFinsupp: Interpret a list as a finitely supported function, where the indexing type isℕ, and the values are either the elements of the list (accessing by indexing) or0outside of the list.
Main theorems
List.toFinsupp_eq_sum_map_enum_single: Al : List MoverManAddMonoid, when interpreted as a finitely supported function, is equal to the sum ofFinsupp.singleproduced by mapping overList.enum l.
Implementation notes
The functions defined here rely on a decidability predicate that each element in the list
can be decidably determined to be not equal to zero or that one can decide one is out of the
bounds of a list. For concretely defined lists that are made up of elements of decidable terms,
this holds. More work will be needed to support lists over non-dec-eq types like ℝ, where the
elements are beyond the dec-eq terms of casted values from ℕ, ℤ, ℚ.
theorem List.toFinsupp.congr_simp E1 #
∀ {M : Type u_1} [inst : Zero M] (l l_1 : List M),
l = l_1 →
∀ {inst_1 : DecidablePred fun x ↦ l.getD x 0 ≠ 0} [inst_2 : DecidablePred fun x ↦ l_1.getD x 0 ≠ 0],
l.toFinsupp = l_1.toFinsupp
def List.toFinsupp E3 #
{M : Type u_1} → [inst : Zero M] → (l : List M) → [DecidablePred fun x ↦ l.getD x 0 ≠ 0] → ℕ →₀ M
Indexing into a l : List M, as a finitely-supported function,
where the support are all the indices within the length of the list
that index to a non-zero value. Indices beyond the end of the list are sent to 0.
This is a computable version of the Finsupp.onFinset construction.
theorem List.coe_toFinsupp E0 #
∀ {M : Type u_1} [inst : Zero M] (l : List M) [inst_1 : DecidablePred fun x ↦ l.getD x 0 ≠ 0],
⇑l.toFinsupp = fun x ↦ l.getD x 0
theorem List.toFinsupp_apply E0 #
∀ {M : Type u_1} [inst : Zero M] (l : List M) [inst_1 : DecidablePred fun x ↦ l.getD x 0 ≠ 0] (i : ℕ),
l.toFinsupp i = l.getD i 0
theorem List.toFinsupp_support E1 #
∀ {M : Type u_1} [inst : Zero M] (l : List M) [inst_1 : DecidablePred fun x ↦ l.getD x 0 ≠ 0],
l.toFinsupp.support = {i ∈ Finset.range l.length | l.getD i 0 ≠ 0}
theorem List.toFinsupp_support_subset E1 #
∀ {M : Type u_1} [inst : Zero M] (l : List M) [inst_1 : DecidablePred fun x ↦ l.getD x 0 ≠ 0],
l.toFinsupp.support ⊆ Finset.range l.length
theorem List.toFinsupp_apply_lt E1 #
∀ {M : Type u_1} [inst : Zero M] (l : List M) [inst_1 : DecidablePred fun x ↦ l.getD x 0 ≠ 0] (n : ℕ)
(hn : n < l.length), l.toFinsupp n = l[n]
theorem List.toFinsupp_apply_fin E1 #
∀ {M : Type u_1} [inst : Zero M] (l : List M) [inst_1 : DecidablePred fun x ↦ l.getD x 0 ≠ 0] (n : Fin l.length),
l.toFinsupp ↑n = l[n]
theorem List.toFinsupp_apply_le E1 #
∀ {M : Type u_1} [inst : Zero M] (l : List M) [inst_1 : DecidablePred fun x ↦ l.getD x 0 ≠ 0] (n : ℕ),
l.length ≤ n → l.toFinsupp n = 0
theorem List.toFinsupp_nil E0 #
∀ {M : Type u_1} [inst : Zero M] [inst_1 : DecidablePred fun i ↦ [].getD i 0 ≠ 0], [].toFinsupp = 0
theorem List.toFinsupp_singleton E1 #
∀ {M : Type u_1} [inst : Zero M] (x : M) [inst_1 : DecidablePred fun x_1 ↦ [x].getD x_1 0 ≠ 0],
[x].toFinsupp = fun₀ | 0 => x
theorem List.toFinsupp_append E1 #
∀ {R : Type u_2} [inst : AddZeroClass R] (l₁ l₂ : List R) [inst_1 : DecidablePred fun x ↦ (l₁ ++ l₂).getD x 0 ≠ 0]
[inst_2 : DecidablePred fun x ↦ l₁.getD x 0 ≠ 0] [inst_3 : DecidablePred fun x ↦ l₂.getD x 0 ≠ 0],
(l₁ ++ l₂).toFinsupp = l₁.toFinsupp + Finsupp.embDomain (addLeftEmbedding l₁.length) l₂.toFinsupp
theorem List.toFinsupp_cons_eq_single_add_embDomain E1 #
∀ {R : Type u_2} [inst : AddZeroClass R] (x : R) (xs : List R)
[inst_1 : DecidablePred fun x_1 ↦ (x :: xs).getD x_1 0 ≠ 0] [inst_2 : DecidablePred fun x ↦ xs.getD x 0 ≠ 0],
(x :: xs).toFinsupp = (fun₀ | 0 => x) + Finsupp.embDomain (addRightEmbedding 1) xs.toFinsupp
theorem List.toFinsupp_concat_eq_toFinsupp_add_single E1 #
∀ {R : Type u_2} [inst : AddZeroClass R] (x : R) (xs : List R) [inst_1 : DecidablePred fun i ↦ (xs ++ [x]).getD i 0 ≠ 0]
[inst_2 : DecidablePred fun i ↦ xs.getD i 0 ≠ 0], (xs ++ [x]).toFinsupp = xs.toFinsupp + fun₀ | xs.length => x
theorem List.toFinsupp_eq_sum_mapIdx_single E1 #
∀ {R : Type u_2} [inst : AddMonoid R] (l : List R) [inst_1 : DecidablePred fun x ↦ l.getD x 0 ≠ 0],
l.toFinsupp = (List.mapIdx (fun n r ↦ fun₀ | n => r) l).sum