Documentation

CslibFrontier.Foundations.Data.List.Flatten

Block boundaries in a flattened list #

A list of blocks L : List (List α), flattened, is read from left to right one block at a time. Block j starts at the length of the first j blocks flattened: dropping that many entries leaves block j followed by the later blocks (List.drop_flatten_take), and the boundary after block j is the one before it plus the length of block j (List.length_flatten_take_succ). Mathlib's List.drop_sum_flatten is a weaker form of the first fact: with the boundary written as a sum of block lengths, dropping that many entries leaves (L.drop j).flatten, without block j split off.

Main results #

theorem List.drop_flatten_take {α : Type u_1} (L : List (List α)) {j : ℕ} (hj : j < L.length) :
drop (take j L).flatten.length L.flatten = L[j] ++ (drop (j + 1) L).flatten

Dropping the first j blocks of a flattened list leaves block j followed by the later blocks.

theorem List.length_flatten_take_succ {α : Type u_1} (L : List (List α)) {j : ℕ} (hj : j < L.length) :

The first j + 1 blocks of a list, flattened, are as long as the first j and block j together.

theorem List.getElem?_flatten_replicate {α : Type u_1} (l : List α) (r j : ℕ) :

The entries of a list repeated r times: entry j is entry j % l.length of l.