List scan #
Prove basic results about List.scanl, List.scanr, List.scanlM and List.scanrM.
List.scanlM and List.scanrM #
List.scanl and List.scanr #
partialSums/partialProd #
@[simp]
theorem
List.partialSums_cons
{α : Type u_1}
{a : α}
[Add α]
[Zero α]
[Std.Associative fun (x1 x2 : α) => x1 + x2]
[Std.LawfulIdentity (fun (x1 x2 : α) => x1 + x2) 0]
{l : List α}
:
theorem
List.partialSums_append
{α : Type u_1}
[Add α]
[Zero α]
[Std.Associative fun (x1 x2 : α) => x1 + x2]
[Std.LawfulIdentity (fun (x1 x2 : α) => x1 + x2) 0]
{l₁ l₂ : List α}
:
@[simp]
theorem
List.getElem_partialSums
{α : Type u_1}
{i : Nat}
[Add α]
[Zero α]
[Std.Associative fun (x1 x2 : α) => x1 + x2]
[Std.LawfulIdentity (fun (x1 x2 : α) => x1 + x2) 0]
{l : List α}
(h : i < l.partialSums.length)
:
theorem
List.partialProds_cons
{α : Type u_1}
{a : α}
[Mul α]
[One α]
[Std.Associative fun (x1 x2 : α) => x1 * x2]
[Std.LawfulIdentity (fun (x1 x2 : α) => x1 * x2) 1]
{l : List α}
:
theorem
List.partialProds_append
{α : Type u_1}
[Mul α]
[One α]
[Std.Associative fun (x1 x2 : α) => x1 * x2]
[Std.LawfulIdentity (fun (x1 x2 : α) => x1 * x2) 1]
{l₁ l₂ : List α}
:
@[simp]
theorem
List.getElem_partialProds
{α : Type u_1}
{i : Nat}
[Mul α]
[One α]
[Std.Associative fun (x1 x2 : α) => x1 * x2]
[Std.LawfulIdentity (fun (x1 x2 : α) => x1 * x2) 1]
{l : List α}
(h : i < l.partialProds.length)
:
flatten #
theorem
List.getElem_flatten
{α : Type u_1}
(L : List (List α))
(i : Nat)
(h : i < L.flatten.length)
:
Indexing into a flattened list: L.flatten[i] equals L[j][k] where
j is the sublist index and k is the offset within that sublist.
The indices are computed as:
jis one less than where the cumulative sum first exceedsikisiminus the total length of the firstjsublists
This theorem states that these indices are in range and the equality holds.