Length, saturation, and decomposition for List.rtake #
A handful of facts about List.rtake (take from the tail) and List.rdrop
(drop from the tail) that mathlib's Mathlib/Data/List/DropRight.lean defines but
leaves without an API: the length of a tail-take, when it saturates to the whole
list, how it absorbs a left append, and the rdrop/rtake decomposition. Each is
the tail mirror of a front-end take lemma and is proved by reducing to it through
List.rtake_eq_reverse_take_reverse — reverse, then take. These flesh out an
under-developed corner of mathlib and are candidates for
Mathlib/Data/List/DropRight.lean.
Main results #
List.length_rtake—(l.rtake n).length = min n l.length.List.length_rtake_le—(l.rtake n).length ≤ n.List.rtake_of_length_le— a short list is its own tail-take.List.rtake_append_of_le_length— a tail-take long enough to fit in the right summand ignores the left one.List.rdrop_append_rtake—l.rdrop n ++ l.rtake n = l, the tail analog ofList.take_append_drop.
A tail-take has length min n l.length — the tail analog of List.length_take.
A tail-take has length at most n — the tail analog of List.length_take_le.
A list no longer than n is its own tail-take — the tail analog of
List.take_of_length_le.
A tail-take that fits inside the right summand ignores the left one — the tail
analog of List.take_append_of_le_length.
Splitting a list at its last n symbols — the tail analog of
List.take_append_drop.